From: Mark Wielaard Date: Thu, 18 Jun 2015 09:50:50 +0000 (+0200) Subject: libdw: Make sure the default page size is big enough to hold a Dwarf. X-Git-Tag: elfutils-0.163~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85cc9c6c72cb90ae06831b2b6618a2584dd0a827;p=thirdparty%2Felfutils.git 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 --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 8970ff6cd..753bcae72 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2015-06-18 Mark Wielaard + + * dwarf_begin_elf.c (dwarf_begin_elf): Assert page size is big enough + to hold a Dwarf. + 2015-06-18 Mark Wielaard * dwarf_getpubnames.c (get_offsets): Always free mem on error. diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index 4e0d590d7..6d38946a3 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);