Skip to content

Commit

Permalink
bug in heap command #568 (fix) (#571)
Browse files Browse the repository at this point in the history
* add support of PIE for r2

* Update radare2.py

API update

* fix bug in command heap

* Update heap.py
  • Loading branch information
matrix1001 authored and disconnect3d committed Feb 27, 2019
1 parent 40d173e commit 0f4e31e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pwndbg/commands/heap.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ def heap(addr=None):


# Print out all chunks on the heap # Print out all chunks on the heap
# TODO: Add an option to print out only free or allocated chunks # TODO: Add an option to print out only free or allocated chunks

# Check if there is an alignment at the start of the heap
size_t = pwndbg.arch.ptrsize
first_chunk_size = pwndbg.arch.unpack(pwndbg.memory.read(addr + size_t, size_t))
if first_chunk_size == 0:
addr += size_t * 2 # Skip the alignment

while addr < page.vaddr + page.memsz: while addr < page.vaddr + page.memsz:
chunk = malloc_chunk(addr) chunk = malloc_chunk(addr) # Prints the chunk
size = int(chunk['size']) size = int(chunk['size'])


# Clear the bottom 3 bits # Clear the bottom 3 bits
Expand Down

0 comments on commit 0f4e31e

Please sign in to comment.