]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
asan: elf.c:12621:18: applying zero offset to null pointer
authorAlan Modra <amodra@gmail.com>
Fri, 16 Dec 2022 07:43:38 +0000 (18:13 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 17 Dec 2022 08:14:42 +0000 (18:44 +1030)
That's this line in elf_parse_notes:
  while (p < buf + size)

* elf.c (_bfd_elf_make_section_from_shdr): Don't call
elf_parse_notes when sh_size is zero.

bfd/elf.c

index 5548efc44e478a663e6327743f0491ff13904c9a..7317c52faaa9d7b176fdfe0dfbf4ff2a2e2ea960 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1110,7 +1110,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
   /* We do not parse the PT_NOTE segments as we are interested even in the
      separate debug info files which may have the segments offsets corrupted.
      PT_NOTEs from the core files are currently not parsed using BFD.  */
-  if (hdr->sh_type == SHT_NOTE)
+  if (hdr->sh_type == SHT_NOTE && hdr->sh_size != 0)
     {
       bfd_byte *contents;