Fix an attempt to allocate an unreasonably large amount of memory when parsing a...
authorNick Clifton <nickc@redhat.com>
Wed, 21 Dec 2022 11:51:23 +0000 (11:51 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 21 Dec 2022 11:51:23 +0000 (11:51 +0000)
PR  29924
* objdump.c (load_specific_debug_section): Check for excessively
large sections.

binutils/ChangeLog
binutils/objdump.c

index e7f918d3f651c95e1aa6b2cc8294979946824a4e..020e09f370053cd31ce322cd5ac914cf70a8f303 100644 (file)
@@ -1,3 +1,9 @@
+2022-12-21  Nick Clifton  <nickc@redhat.com>
+
+       PR  29924
+       * objdump.c (load_specific_debug_section): Check for excessively
+       large sections.
+
 2022-12-19  Tom Tromey  <tromey@adacore.com>
 
        * dwarf-mode.el (dwarf-do-refresh): Avoid compiler warning.
index d51abbe38581dbd19fa7e96622aa4fa421b38830..2eb02de0e76043b09d7bd4a09f73cec3d2bbaf47 100644 (file)
@@ -4225,7 +4225,9 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
   section->size = bfd_section_size (sec);
   /* PR 24360: On 32-bit hosts sizeof (size_t) < sizeof (bfd_size_type). */
   alloced = amt = section->size + 1;
-  if (alloced != amt || alloced == 0)
+  if (alloced != amt
+      || alloced == 0
+      || (bfd_get_size (abfd) != 0 && alloced >= bfd_get_size (abfd)))
     {
       section->start = NULL;
       free_debug_section (debug);