From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] kvx: asan: out-of-bounds read
Date: Wed, 23 Aug 2023 01:46:45 +0000 (GMT) [thread overview]
Message-ID: <20230823014645.345043858C53@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=847fb383d83039b194f68d9e09974a3de4095eb5
commit 847fb383d83039b194f68d9e09974a3de4095eb5
Author: Alan Modra <amodra@gmail.com>
Date: Wed Aug 23 08:18:39 2023 +0930
kvx: asan: out-of-bounds read
kvx-parse.c:parse_with_restarts does
if (!tok.insn[tok.begin])
tok.class_id = -3;
then a little later
printf_debug (1, "\nEntering rule: %d (Trying to match: (%s)[%d])\n", jump_target,
TOKEN_NAME (CLASS_ID (tok)), CLASS_ID (tok));
This results in a buffer overrun in TOKEN_NAME. Fix that.
* config/tc-kvx.h (TOKEN_NAME): Check for tok <= 0, not just -1.
Diff:
---
gas/config/tc-kvx.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gas/config/tc-kvx.h b/gas/config/tc-kvx.h
index 11787bf0532..85344cbe179 100644
--- a/gas/config/tc-kvx.h
+++ b/gas/config/tc-kvx.h
@@ -37,7 +37,8 @@
#define KVX_RA_REGNO (67)
#define KVX_SP_REGNO (12)
-#define TOKEN_NAME(tok) ((tok) == -1 ? "unknown token" : env.tokens_names[(tok) - 1])
+#define TOKEN_NAME(tok) \
+ ((tok) <= 0 ? "unknown token" : env.tokens_names[(tok) - 1])
struct token_s {
char *insn;
reply other threads:[~2023-08-23 1:46 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=20230823014645.345043858C53@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).