This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] 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 <mjw@redhat.com>
---
 libdw/ChangeLog         | 5 +++++
 libdw/dwarf_begin_elf.c | 1 +
 2 files changed, 6 insertions(+)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 8970ff6..753bcae 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,10 @@
 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.
 
 2015-06-18  Mark Wielaard  <mjw@redhat.com>
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 4e0d590..6d38946 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);
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]