public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Fix an illegal memorty access when running gprof over corrupt data.
Date: Tue, 11 Apr 2023 15:23:02 +0000 (GMT)	[thread overview]
Message-ID: <20230411152302.0BDFD3858D32@sourceware.org> (raw)

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

commit 91496180eba5150fb169c5edaff16877eefae7f9
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Apr 11 16:22:28 2023 +0100

    Fix an illegal memorty access when running gprof over corrupt data.
    
      PR 30324
      * symtab.c (symtab_finalize): Only change the end address if dst has been updated.

Diff:
---
 gprof/ChangeLog | 6 ++++++
 gprof/symtab.c  | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gprof/ChangeLog b/gprof/ChangeLog
index d49b1894905..33a95f272fa 100644
--- a/gprof/ChangeLog
+++ b/gprof/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-11  Nick Clifton  <nickc@redhat.com>
+
+	PR 30324
+	* symtab.c (symtab_finalize): Only change the end address if dst
+	has been updated.
+
 2023-02-20  Nick Clifton  <nickc@redhat.com>
 
 	* po/ms.po: Updated Malayasian translation.
diff --git a/gprof/symtab.c b/gprof/symtab.c
index ea47aac47b5..61feebc5d02 100644
--- a/gprof/symtab.c
+++ b/gprof/symtab.c
@@ -147,7 +147,7 @@ symtab_finalize (Sym_Table *tab)
 	}
     }
 
-  if (tab->len > 0 && dst[-1].end_addr == 0)
+  if (tab->len > 0 && dst > tab->base && dst[-1].end_addr == 0)
     dst[-1].end_addr
       = core_text_sect->vma + bfd_section_size (core_text_sect) - 1;

                 reply	other threads:[~2023-04-11 15:23 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=20230411152302.0BDFD3858D32@sourceware.org \
    --to=nickc@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).