addr2line out of memory on fuzzed file
authorAlan Modra <amodra@gmail.com>
Wed, 4 Jan 2023 11:09:54 +0000 (21:39 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 4 Jan 2023 13:22:26 +0000 (23:52 +1030)
Another case of fuzzers finding the section size sanity checks are
avoided with SHT_NOBITS sections.

* dwarf2.c (read_section): Check that the DWARF section being
read has contents.

bfd/dwarf2.c

index 6eb6e04e6e5b1386c2a99bc65becf8680ada4176..f689eebbd88d2d68b624a768e037c4e6276c9683 100644 (file)
@@ -705,6 +705,14 @@ read_section (bfd *abfd,
          return false;
        }
 
+      if ((msec->flags & SEC_HAS_CONTENTS) == 0)
+       {
+         _bfd_error_handler (_("DWARF error: section %s has no contents"),
+                             section_name);
+         bfd_set_error (bfd_error_no_contents);
+         return false;
+       }
+
       if (_bfd_section_size_insane (abfd, msec))
        {
          /* PR 26946 */