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