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] buffer overflow in print_symname
Date: Wed, 19 Apr 2023 23:34:35 +0000 (GMT)	[thread overview]
Message-ID: <20230419233435.878523858417@sourceware.org> (raw)

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

commit 685b44ee816c6e508d282ae3766f2441b5ae9334
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Apr 19 21:53:18 2023 +0930

    buffer overflow in print_symname
    
            * ecoff.c (_bfd_ecoff_slurp_symbolic_info): Zero terminate
            string sections.

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

diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index fb6fcade913..676b8d84017 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -599,6 +599,12 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
   FIX (cbExtOffset, iextMax, external_ext, void *);
 #undef FIX
 
+  /* Ensure string sections are zero terminated.  */
+  if (debug->ss)
+    debug->ss[internal_symhdr->issMax - 1] = 0;
+  if (debug->ssext)
+    debug->ssext[internal_symhdr->issExtMax - 1] = 0;
+
   /* I don't want to always swap all the data, because it will just
      waste time and most programs will never look at it.  The only
      time the linker needs most of the debugging information swapped

                 reply	other threads:[~2023-04-19 23:34 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=20230419233435.878523858417@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).