From: Mark Wielaard Date: Fri, 29 Mar 2019 09:53:27 +0000 (+0100) Subject: readelf: print_debug_macinfo_section, check cus[0] is not the sentinel. X-Git-Tag: elfutils-0.177~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34ff3ca2e86f8a4915500b92a8e00d6f52aa546c;p=thirdparty%2Felfutils.git readelf: print_debug_macinfo_section, check cus[0] is not the sentinel. If there are no CUs at all we can not find any CU DIE file. https://sourceware.org/bugzilla/show_bug.cgi?id=24398 Signed-off-by: Mark Wielaard --- diff --git a/src/ChangeLog b/src/ChangeLog index fb1ac0964..99ca1b757 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,11 @@ +2019-03-29 Mark Wielaard + + * readelf.c (print_debug_macinfo_section): Check cus[0] is not the + sentinel. + 2019-03-27 Mark Wielaard - * strip (handle_elf): Assert that symbol section number exists. + * strip.c (handle_elf): Assert that symbol section number exists. 2019-01-24 Mark Wielaard diff --git a/src/readelf.c b/src/readelf.c index 33706bdef..5654fd1e8 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -9688,13 +9688,13 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)), /* Find the CU DIE for this file. */ size_t macoff = readp - (const unsigned char *) data->d_buf; const char *fname = "???"; - if (macoff >= cus[0].offset) + if (macoff >= cus[0].offset && cus[0].offset != data->d_size) { while (macoff >= cus[1].offset && cus[1].offset != data->d_size) ++cus; if (cus[0].files == NULL - && dwarf_getsrcfiles (&cus[0].die, &cus[0].files, NULL) != 0) + && dwarf_getsrcfiles (&cus[0].die, &cus[0].files, NULL) != 0) cus[0].files = (Dwarf_Files *) -1l; if (cus[0].files != (Dwarf_Files *) -1l)