diff options
| author | Mark Wielaard <[email protected]> | 2015-06-18 11:50:50 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2015-06-19 12:49:13 +0200 |
| commit | 85cc9c6c72cb90ae06831b2b6618a2584dd0a827 (patch) | |
| tree | 426abb7827f49f317474b7e6d9bd8d5657f852d6 | |
| parent | 9beaa94e56fb8b717f838e02905e100647138bf9 (diff) | |
libdw: Make sure the default page size is big enough to hold a Dwarf.
Just assert early that the page size isn't unreasonable small instead of
corrupting memory later.
Signed-off-by: Mark Wielaard <[email protected]>
| -rw-r--r-- | libdw/ChangeLog | 5 | ||||
| -rw-r--r-- | libdw/dwarf_begin_elf.c | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 8970ff6c..753bcae7 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,10 @@ 2015-06-18 Mark Wielaard <[email protected]> + * dwarf_begin_elf.c (dwarf_begin_elf): Assert page size is big enough + to hold a Dwarf. + +2015-06-18 Mark Wielaard <[email protected]> + * dwarf_getpubnames.c (get_offsets): Always free mem on error. 2015-06-18 Mark Wielaard <[email protected]> diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index 4e0d590d..6d38946a 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -365,6 +365,7 @@ dwarf_begin_elf (elf, cmd, scngrp) /* Default memory allocation size. */ size_t mem_default_size = sysconf (_SC_PAGESIZE) - 4 * sizeof (void *); + assert (sizeof (struct Dwarf) < mem_default_size); /* Allocate the data structure. */ Dwarf *result = (Dwarf *) calloc (1, sizeof (Dwarf) + mem_default_size); |
