From: Alan Modra Date: Wed, 4 Jan 2023 11:09:54 +0000 (+1030) Subject: addr2line out of memory on fuzzed file X-Git-Tag: binutils-2_41~2511 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efff45b40a10ab0b3bdc16c3f20cf4af3f6dea88;p=thirdparty%2Fbinutils-gdb.git addr2line out of memory on fuzzed file 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. --- diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 6eb6e04e6e5..f689eebbd88 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -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 */