[PATCH] libdw: dwarf_getpubnames set error to DWARF_E_NO_ENTRY for zero entries.

Mark Wielaard mjw at redhat.com
Mon Dec 15 15:59:27 UTC 2014


realloc in get_offsets will return NULL otherwise and dwarf_getpubnames
might think there was no issue and try to use that NULL pointer.

Signed-off-by: Mark Wielaard <mjw at redhat.com>
---
 libdw/ChangeLog           | 2 +-
 libdw/dwarf_getpubnames.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 93651df..2aa878b 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,7 +1,7 @@
 2014-12-15  Mark Wielaard  <mjw at redhat.com>
 
 	* dwarf_getpubnames.c (get_offsets): Make sure whole unit fall inside
-	section data.
+	section data. Set error to DWARF_E_NO_ENTRY if cnt is zero.
 	(dwarf_getpubnames): Make sure section data contains string zero
 	terminator.
 
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c
index c8b9f9f..9fbfcbf 100644
--- a/libdw/dwarf_getpubnames.c
+++ b/libdw/dwarf_getpubnames.c
@@ -125,7 +125,7 @@ get_offsets (Dwarf *dbg)
       readp += len;
     }
 
-  if (mem == NULL)
+  if (mem == NULL || cnt == 0)
     {
       __libdw_seterrno (DWARF_E_NO_ENTRY);
       return -1;
-- 
1.8.3.1



More information about the elfutils-devel mailing list