public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Yet another ecoff fuzzed object fix
Date: Mon,  5 Jun 2023 07:18:21 +0000 (GMT)	[thread overview]
Message-ID: <20230605071821.C8CD63856617@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fc018e9e593a3235dbf7026726ba4665373b741

commit 6fc018e9e593a3235dbf7026726ba4665373b741
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Jun 5 16:21:25 2023 +0930

    Yet another ecoff fuzzed object fix
    
            * 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.

Diff:
---
 bfd/ecoff.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index c4c2e530be0..573f52d0299 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -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;

                 reply	other threads:[~2023-06-05  7:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230605071821.C8CD63856617@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).