]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Don't try to read macinfo cus sentinel or beyond.
authorMark Wielaard <mjw@redhat.com>
Sun, 21 Dec 2014 22:02:12 +0000 (23:02 +0100)
committerMark Wielaard <mjw@redhat.com>
Mon, 12 Jan 2015 21:01:13 +0000 (22:01 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1170810

Reported-by: Alexander Cherepanov <cherepan@mccme.ru>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/readelf.c

index 00a587cd189e9969c489db5a8852eace55681683..7203dd956d8cb87fc623060543fadb4b5662e4d6 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-20  Mark Wielaard  <mjw@redhat.com>
+
+       * readelf.c (print_debug_macinfo_section): Mark cus sentinel files
+       as -1 non-existent. Check macoff against sentinel cus.
+
 2014-12-20  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (print_debug_exception_table): Add max_action overflow
index a05b2382e3462574b34bb9970bbcd6c4626dd7a3..237975f95ec7a69c96917ef3214073cdc782fa97 100644 (file)
@@ -7061,6 +7061,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
                                                         * sizeof (*cus));
   /* Add sentinel.  */
   cus[nculist].offset = data->d_size;
+  cus[nculist].files = (Dwarf_Files *) -1l;
   if (nculist > 0)
     {
       for (size_t cnt = nculist - 1; culist != NULL; --cnt)
@@ -7136,7 +7137,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
          const char *fname = "???";
          if (macoff >= cus[0].offset)
            {
-             while (macoff >= cus[1].offset)
+             while (macoff >= cus[1].offset && cus[1].offset != data->d_size)
                ++cus;
 
              if (cus[0].files == NULL