angr.analyses.reaching_definitions.heap_allocator

class angr.analyses.reaching_definitions.heap_allocator.HeapAllocator

Bases: object

A simple modelisation to help represent heap memory management during a <ReachingDefinitionsAnalysis>: - Act as if allocations were always done in consecutive memory segments; - Take care of the size not to screw potential pointer arithmetic (avoid overlapping segments).

The content of the heap itself is modeled using a <KeyedRegion> attribute in the <LiveDefinitions> state; This class serves to generate consistent heap addresses to be used by the aforementioned.

Note: This has NOT been made to help detect heap vulnerabilities.

__init__(canonical_size)
Parameters:

canonical_size (int) – The concrete size an <UNKNOWN_SIZE> defaults to.

allocate(size)

Gives an address for a new memory chunk of <size> bytes.

Parameters:

size (int | UnknownSize) – The requested size for the chunk, in number of bytes.

Return type:

HeapAddress

Returns:

The address of the chunk.

free(address)

Mark the chunk pointed by <address> as freed.

Parameters:

address (Undefined | HeapAddress) – The address of the chunk to free.

property allocated_addresses

The list of addresses that are currently allocated on the heap.

Type:

return