]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Re: stab nearest_line bfd_malloc_and_get_section
authorAlan Modra <amodra@gmail.com>
Tue, 4 Oct 2022 23:57:46 +0000 (10:27 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 5 Oct 2022 04:23:41 +0000 (14:53 +1030)
It didn't take long for the fuzzers to avoid size checks in
bfd_malloc_and_get_section.  Plug this hole.

* syms.c (_bfd_stab_section_find_nearest_line): Ignore fuzzed
sections with no contents.

bfd/syms.c

index e8077f59bf0c566bc3d60068d11637aab7a1d50c..c9d27ebe5d440d466ed5c231ccbf188ff0d5fd6d 100644 (file)
@@ -1019,6 +1019,10 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
            return true;
        }
 
+      if ((info->stabsec->flags & SEC_HAS_CONTENTS) == 0
+         || (info->strsec->flags & SEC_HAS_CONTENTS) == 0)
+       goto out;
+
       stabsize = (info->stabsec->rawsize
                  ? info->stabsec->rawsize
                  : info->stabsec->size);