]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix free of unallocated memory in the BFD library's compression code.
authorNick Clifton <nickc@redhat.com>
Tue, 19 Mar 2024 12:48:04 +0000 (12:48 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 19 Mar 2024 12:48:04 +0000 (12:48 +0000)
  PR 31455

bfd/compress.c

index 8bc44de813b10e28afa9558f52312181056369ad..38eb18233999f53ca6c568531a2a45e2e8ef5b18 100644 (file)
@@ -585,6 +585,10 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec)
   if (compressed && orig_header_size < 0)
     abort ();
 
+  /* PR 31455: Check for a corrupt uncompressed size.  */
+  if (uncompressed_size == (bfd_size_type) -1)
+    return uncompressed_size;
+
   /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size,
      overhead in .zdebug* section.  */
   if (!new_header_size)