vis: interpret count as addr if its big enough (#2342)

pull/2343/head^2
k4lizen 1 year ago committed by GitHub
parent 54144198f2
commit 8f78932c5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -21,7 +21,7 @@ usage: vis_heap_chunks [-h] [--beyond_top] [--no_truncate] [--all_chunks] [count
|Positional Argument|Help|
| :--- | :--- |
|`count`|Number of chunks to visualize. (default: %(default)s)|
|`count`|Number of chunks to visualize. If the value is big enough and addr isn't provided, this is interpreted as addr instead. (default: %(default)s)|
|`addr`|Address of the first chunk.|
## Optional Arguments

@ -944,7 +944,7 @@ group.add_argument(
nargs="?",
type=lambda n: max(int(n, 0), 1),
default=pwndbg.config.default_visualize_chunk_number,
help="Number of chunks to visualize.",
help="Number of chunks to visualize. If the value is big enough and addr isn't provided, this is interpreted as addr instead.",
)
parser.add_argument("addr", nargs="?", default=None, help="Address of the first chunk.")
parser.add_argument(
@ -985,6 +985,11 @@ def vis_heap_chunks(
allocator = pwndbg.gdblib.heap.current
assert isinstance(allocator, GlibcMemoryAllocator)
# If the first argument (count) is big enough (and address isn't provided) interpret it as an address
if addr is None and count is not None and count > 0x1000:
addr = count
count = pwndbg.config.default_visualize_chunk_number
if addr is not None:
cursor = int(addr)
heap_region = Heap(cursor)

Loading…
Cancel
Save