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] Re: More ecoff sanity checks
Date: Fri,  2 Jun 2023 00:12:19 +0000 (GMT)	[thread overview]
Message-ID: <20230602001219.CC9933857735@sourceware.org> (raw)

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

commit e0ce6dde97881435d33652572789b94c846cacde
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jun 2 08:21:36 2023 +0930

    Re: More ecoff sanity checks
    
    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.

Diff:
---
 bfd/ecoff.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 676b8d84017..f2930569f21 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -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);

             reply	other threads:[~2023-06-02  0:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02  0:12 Alan Modra [this message]
2023-06-03  8:06 Alan Modra

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=20230602001219.CC9933857735@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).