Skip to content

Commit

Permalink
[tests] fixed heap set-arena
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jan 11, 2022
1 parent c25f9c1 commit 29a9925
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions gef.py
Expand Up @@ -1208,11 +1208,14 @@ def __init__(self, addr: str) -> None:
self.__arena = MallocStateStruct(addr)
self.__addr = self.__arena.addr

self.top = int(self.top)
self.last_remainder = int(self.last_remainder)
self.n = int(self.next)
self.nfree = int(self.next_free)
self.sysmem = int(self.system_mem)
try:
self.top = int(self.top)
self.last_remainder = int(self.last_remainder)
self.n = int(self.next)
self.nfree = int(self.next_free)
self.sysmem = int(self.system_mem)
except gdb.error as e:
err("Glibc arena: {}".format(e))
return

def __getitem__(self, item):
Expand Down Expand Up @@ -1294,7 +1297,7 @@ def __str__(self):
fmt = "{:s}(base={:#x}, top={:#x}, last_remainder={:#x}, next={:#x}, next_free={:#x}, system_mem={:#x})"
return fmt.format(
Color.colorify("Arena", "blue bold underline"),
self.__addr, self.top, self.last_remainder, self.next, self.nfree, self.sysmem
self.__addr, self.top, self.last_remainder, self.n, self.nfree, self.sysmem
)


Expand Down Expand Up @@ -6789,7 +6792,7 @@ class GlibcHeapSetArenaCommand(GenericCommand):
"""Display information on a heap chunk."""

_cmdline_ = "heap set-arena"
_syntax_ = "{:s} [address|symbol]".format(_cmdline_)
_syntax_ = "{:s} [address|&symbol]".format(_cmdline_)
_example_ = "{:s} 0x001337001337".format(_cmdline_)

def __init__(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/runtests.py
Expand Up @@ -215,7 +215,7 @@ def test_cmd_heap_arenas(self):
return

def test_cmd_heap_set_arena(self):
cmd = "heap set-arena main_arena"
cmd = "heap set-arena &main_arena"
target = _target("heap")
self.assertFailIfInactiveSession(gdb_run_cmd(cmd, target=target))
res = gdb_run_silent_cmd(cmd, target=target, after=["heap arenas"])
Expand Down

0 comments on commit 29a9925

Please sign in to comment.