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: dwarf_getpubnames set error to DWARF_E_NO_ENTRY for zero entries.


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@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@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


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