From: Mark Wielaard Date: Mon, 15 Dec 2014 15:56:49 +0000 (+0100) Subject: libdw: dwarf_getpubnames set error to DWARF_E_NO_ENTRY for zero entries. X-Git-Tag: elfutils-0.161~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=138a9ba2be7e2df2423f86c9ddcca7322648e426;p=thirdparty%2Felfutils.git 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 --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 068d45212..f1f7b1d16 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,7 +1,7 @@ 2014-12-15 Mark Wielaard * 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 c8b9f9f6c..9fbfcbf3d 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;