[binutils-gdb] Fix free of unallocated memory in the BFD library's compression code.

Nick Clifton nickc@sourceware.org
Tue Mar 19 12:48:42 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2c16eb1d8346f0d390f5278d5ff187854c2d5879

commit 2c16eb1d8346f0d390f5278d5ff187854c2d5879
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Mar 19 12:48:04 2024 +0000

    Fix free of unallocated memory in the BFD library's compression code.
    
      PR 31455

Diff:
---
 bfd/compress.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bfd/compress.c b/bfd/compress.c
index 8bc44de813b..38eb1823399 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -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)


More information about the Binutils-cvs mailing list