Extend previous patch to cover uncompress_section_contents returning FALSE to other...
authorNick Clifton <nickc@redhat.com>
Mon, 13 Feb 2017 15:19:48 +0000 (15:19 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 13 Feb 2017 15:19:48 +0000 (15:19 +0000)
PR binutils/21135
(dump_section_as_bytes, load_specific_debug_section): Likewise.

binutils/ChangeLog
binutils/readelf.c

index fdd5f33c737d2fc338c9c40cdb50c78faf1213b3..294e66ce44b7d0a9dc93515fe0839b1885c6f9cc 100644 (file)
@@ -3,6 +3,7 @@
        PR binutils/21135
        * readelf.c (dump_section_as_bytes): Handle the case where
        uncompress_section_contents returns false.
+       (dump_section_as_bytes, load_specific_debug_section): Likewise.
 
 2017-02-13  Nick Clifton  <nickc@redhat.com>
 
index ede5747e40d00ea26d32cacefabd4860d4ec72f4..c73a3275ea3a087a671f7d771cab990cde1a3640 100644 (file)
@@ -12691,10 +12691,18 @@ dump_section_as_strings (Elf_Internal_Shdr * section, FILE * file)
          new_size -= 12;
        }
 
-      if (uncompressed_size
-         && uncompress_section_contents (& start,
-                                         uncompressed_size, & new_size))
-       num_bytes = new_size;
+      if (uncompressed_size)
+       {
+         if (uncompress_section_contents (& start,
+                                          uncompressed_size, & new_size))
+           num_bytes = new_size;
+         else
+           {
+             error (_("Unable to decompress section %s\n"),
+                    printable_section_name (section));
+             return;
+           }
+       }
     }
 
   /* If the section being dumped has relocations against it the user might
@@ -12986,14 +12994,22 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
          size -= 12;
        }
 
-      if (uncompressed_size
-         && uncompress_section_contents (&start, uncompressed_size,
-                                         &size))
+      if (uncompressed_size)
        {
-         /* Free the compressed buffer, update the section buffer
-            and the section size if uncompress is successful.  */
-         free (section->start);
-         section->start = start;
+         if (uncompress_section_contents (&start, uncompressed_size,
+                                          &size))
+           {
+             /* Free the compressed buffer, update the section buffer
+                and the section size if uncompress is successful.  */
+             free (section->start);
+             section->start = start;
+           }
+         else
+           {
+             error (_("Unable to decompress section %s\n"),
+                    printable_section_name (sec));
+             return 0;
+           }
        }
       section->size = size;
     }