From 8db8f4d25a893874c902232663e7fdccaa1cae4c Mon Sep 17 00:00:00 2001 From: veritas501 Date: Fri, 4 Jun 2021 10:54:51 +0800 Subject: [PATCH] fix: update_length() raise exception in some cases This is the case: ``` pwndbg> show print elements Limit on string chars or array elements to print is 200. warning: (Internal error: pc 0x7ffff49ef495 in read in CU, but not in symtab.) warning: (Internal error: pc 0x7ffff49ef495 in read in CU, but not in symtab.) warning: (Internal error: pc 0x7ffff49ef495 in read in CU, but not in symtab.) warning: (Internal error: pc 0x7ffff49ef495 in read in CU, but not in symtab.) Exception occurred: Error: invalid literal for int() with base 10: 'symtab.)' () For more info invoke `set exception-verbose on` and rerun the command or debug it by yourself with `set exception-debugger on` Python Exception invalid literal for int() with base 10: 'symtab.)': ``` If we call `message = message.split()[-1]`, we get `symtab.)`. Then `length = int(message)` raise an Exception. --- pwndbg/strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwndbg/strings.py b/pwndbg/strings.py index 63217b09e..1bc0fdae3 100644 --- a/pwndbg/strings.py +++ b/pwndbg/strings.py @@ -25,7 +25,7 @@ def update_length(): """ global length message = gdb.execute('show print elements', from_tty=False, to_string=True) - message = message.split()[-1] + message = message.split('\n')[0].split()[-1] message = message.strip('.') if message == 'unlimited': length = 0