]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Make sure the default page size is big enough to hold a Dwarf.
authorMark Wielaard <mjw@redhat.com>
Thu, 18 Jun 2015 09:50:50 +0000 (11:50 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 19 Jun 2015 10:49:13 +0000 (12:49 +0200)
Just assert early that the page size isn't unreasonable small instead of
corrupting memory later.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_begin_elf.c

index 8970ff6cd49f40a12274a7cea4ddd25c50f93429..753bcae72d5d458bf6fb3aa0c24acb1838d23187 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-18  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_begin_elf.c (dwarf_begin_elf): Assert page size is big enough
+       to hold a Dwarf.
+
 2015-06-18  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf_getpubnames.c (get_offsets): Always free mem on error.
index 4e0d590d7ab46bdb12d62f47f4ef5ca0c4457aa0..6d38946a387044e3e3fecde189aab0f95299dc48 100644 (file)
@@ -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);