public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim: bfin: avoid stack error under asan [committed]
Date: Sat, 26 Dec 2015 23:24:00 -0000	[thread overview]
Message-ID: <1451172264-21568-1-git-send-email-vapier@gentoo.org> (raw)

We set up an array of 3 elements and then index into it with a 2bit
value.  We check the range before we actually use the pointer, but
the indexing is enough to make asan upset, so just stuff a fourth
value in there to keep things simple.
---
 sim/bfin/ChangeLog  | 4 ++++
 sim/bfin/bfin-sim.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog
index 6717fcc..fb00c8b 100644
--- a/sim/bfin/ChangeLog
+++ b/sim/bfin/ChangeLog
@@ -1,5 +1,9 @@
 2015-12-26  Mike Frysinger  <vapier@gentoo.org>
 
+	* bfin-sim.c (decode_LDST_0): Add 4th element to posts array.
+
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
 	* interp.c (sim_create_inferior): Update comment and argv check.
 
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
diff --git a/sim/bfin/bfin-sim.c b/sim/bfin/bfin-sim.c
index b6acb4e..9737bc1 100644
--- a/sim/bfin/bfin-sim.c
+++ b/sim/bfin/bfin-sim.c
@@ -3292,7 +3292,7 @@ decode_LDST_0 (SIM_CPU *cpu, bu16 iw0)
   int aop = ((iw0 >> LDST_aop_bits) & LDST_aop_mask);
   int reg = ((iw0 >> LDST_reg_bits) & LDST_reg_mask);
   int ptr = ((iw0 >> LDST_ptr_bits) & LDST_ptr_mask);
-  const char * const posts[] = { "++", "--", "" };
+  const char * const posts[] = { "++", "--", "", "<INV>" };
   const char *post = posts[aop];
   const char *ptr_name = get_preg_name (ptr);
 
-- 
2.6.2

                 reply	other threads:[~2015-12-26 23:24 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=1451172264-21568-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@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).