Fix NULL pointer indirection when parsing corrupt DWARF data.
authorNick Clifton <nickc@redhat.com>
Mon, 27 Jun 2022 12:30:35 +0000 (13:30 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 27 Jun 2022 12:30:35 +0000 (13:30 +0100)
PR 29290
* dwarf.c (read_and_display_attr_value): Check that debug_info_p
is set before dereferencing it.

binutils/ChangeLog
binutils/dwarf.c

index 48a3750c52d8c53dde595183d51adbed1977e3ec..7c547e67eab8ee3e8110643b757c27e9a34fccfc 100644 (file)
@@ -1,7 +1,14 @@
+2022-06-27  Nick Clifton  <nickc@redhat.com>
+
+       PR 29290
+       * dwarf.c (read_and_display_attr_value): Check that debug_info_p
+       is set before dereferencing it.
+
 2022-06-27  Nick Clifton  <nickc@redhat.com>
 
        * dwarf.c (fetch_indexed_string): Do not use length of first table
        in string section as the length of every table in the section.
+
        * testsuite/binutils-all/pr26112.r: Update expected output.
 
 2022-06-22  Kumar N, Bhuvanendra  <Kavitha.Natarajan@amd.com>
index bcabb61b871a9d5d38443c1d39e8b9a49134572e..37b477b886d17b800d96b50d2fd96c725eb7d4aa 100644 (file)
@@ -2694,18 +2694,17 @@ read_and_display_attr_value (unsigned long           attribute,
        {
          const char *suffix = section ? strrchr (section->name, '.') : NULL;
          bool dwo = suffix && strcmp (suffix, ".dwo") == 0;
+         const char *strng;
 
+         strng = fetch_indexed_string (uvalue, this_set, offset_size, dwo,
+                                       debug_info_p ? debug_info_p->str_offsets_base : 0);
          if (do_wide)
            /* We have already displayed the form name.  */
            printf (_("%c(offset: 0x%s): %s"), delimiter,
-                   dwarf_vmatoa ("x", uvalue),
-                   fetch_indexed_string (uvalue, this_set, offset_size, dwo,
-                                         debug_info_p->str_offsets_base));
+                   dwarf_vmatoa ("x", uvalue), strng);
          else
            printf (_("%c(indexed string: 0x%s): %s"), delimiter,
-                   dwarf_vmatoa ("x", uvalue),
-                   fetch_indexed_string (uvalue, this_set, offset_size, dwo,
-                                         debug_info_p->str_offsets_base));
+                   dwarf_vmatoa ("x", uvalue), strng);
        }
       break;