Yet another ecoff fuzzed object fix
authorAlan Modra <amodra@gmail.com>
Mon, 5 Jun 2023 06:51:25 +0000 (16:21 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 5 Jun 2023 07:17:44 +0000 (16:47 +0930)
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check fdr_ptr
csym against remaining space for symbols.  Error on out of bounds
fdr_ptr fields.

bfd/ecoff.c

index c4c2e530be0287fb5b13f495390762b4d7cd95fa..573f52d029908d613790f2e636ff5f4237f4cc92 100644 (file)
@@ -956,13 +956,19 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd)
       char *lraw_end;
       HDRR *symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
 
+      if (fdr_ptr->csym == 0)
+       continue;
       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 < 0
+         || fdr_ptr->csym > ((long) bfd_get_symcount (abfd)
+                             - (internal_ptr - internal))
          || fdr_ptr->issBase < 0
          || fdr_ptr->issBase > symhdr->issMax)
-       continue;
+       {
+         bfd_set_error (bfd_error_bad_value);
+         return false;
+       }
       lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym
                  + fdr_ptr->isymBase * external_sym_size);
       lraw_end = lraw_src + fdr_ptr->csym * external_sym_size;