Re: More ecoff sanity checks
authorAlan Modra <amodra@gmail.com>
Thu, 1 Jun 2023 22:51:36 +0000 (08:21 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 2 Jun 2023 00:11:49 +0000 (09:41 +0930)
Another fix for fuzzed object files, exhibiting as a segfault in
nm.c filter_symbols when accessing a symbol name.

* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check
fdr_ptr->issBase, and tighten sym.iss check.

bfd/ecoff.c

index 676b8d840176501169f72ed63fcc3e462dc98d17..f2930569f21476343e37a0c3a4dfd3dcaacf984f 100644 (file)
@@ -942,7 +942,9 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd)
       if (fdr_ptr->isymBase < 0
          || fdr_ptr->isymBase > symhdr->isymMax
          || fdr_ptr->csym <= 0
-         || fdr_ptr->csym > symhdr->isymMax - fdr_ptr->isymBase)
+         || fdr_ptr->csym > symhdr->isymMax - fdr_ptr->isymBase
+         || fdr_ptr->issBase < 0
+         || fdr_ptr->issBase > symhdr->issMax)
        continue;
       lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
                  + fdr_ptr->isymBase * external_sym_size);
@@ -955,7 +957,7 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd)
 
          (*swap_sym_in) (abfd, (void *) lraw_src, &internal_sym);
 
-         if (internal_sym.iss >= symhdr->issMax
+         if (internal_sym.iss >= symhdr->issMax - fdr_ptr->issBase
              || internal_sym.iss < 0)
            {
              bfd_set_error (bfd_error_bad_value);