From 37c4f8ca21402937b45021714750ab384b4d4bbd Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Sun, 17 May 2015 11:52:03 -0400 Subject: [PATCH] Bugfixes, make errno better --- pwndbg/commands/misc.py | 4 ++-- pwndbg/disasm/__init__.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pwndbg/commands/misc.py b/pwndbg/commands/misc.py index 955ae1c62..9f356a1f4 100644 --- a/pwndbg/commands/misc.py +++ b/pwndbg/commands/misc.py @@ -13,8 +13,8 @@ _errno.errorcode[0] = 'OK' @_pwndbg.commands.ParsedCommand def errno(err=None): if err is None: - err = _pwndbg.regs.retval - err = _pwndbg.regs[err] + # Dont ask. + err = int(gdb.parse_and_eval('*((int *(*) (void)) __errno_location) ()')) err = abs(int(err)) diff --git a/pwndbg/disasm/__init__.py b/pwndbg/disasm/__init__.py index ae22bf3eb..36d47b324 100644 --- a/pwndbg/disasm/__init__.py +++ b/pwndbg/disasm/__init__.py @@ -104,6 +104,9 @@ def get(address, instructions=1): def near(address, instructions=1): current = one(address) + if not current: + return [] + # Try to go backward by seeing which instructions we've returned # before, which were followed by this one. needle = address