From patchwork Sat Dec 26 23:24:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 10142 Received: (qmail 37855 invoked by alias); 26 Dec 2015 23:24:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 37841 invoked by uid 89); 26 Dec 2015 23:24:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=inv, Hx-languages-length:1381, upset, posts X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 26 Dec 2015 23:24:30 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 182E1340564 for ; Sat, 26 Dec 2015 23:24:28 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: bfin: avoid stack error under asan [committed] Date: Sat, 26 Dec 2015 18:24:24 -0500 Message-Id: <1451172264-21568-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes 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 + * bfin-sim.c (decode_LDST_0): Add 4th element to posts array. + +2015-12-26 Mike Frysinger + * interp.c (sim_create_inferior): Update comment and argv check. 2015-12-25 Mike Frysinger 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[] = { "++", "--", "", "" }; const char *post = posts[aop]; const char *ptr_name = get_preg_name (ptr);