From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] ubsan: aarch64 parse_vector_reg_list
Date: Sun, 2 Apr 2023 22:24:34 +0000 (GMT) [thread overview]
Message-ID: <20230402222434.8BDBD385800C@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f679aaa4c8fd6f72a8e2d60aba2c88127133101a
commit f679aaa4c8fd6f72a8e2d60aba2c88127133101a
Author: Alan Modra <amodra@gmail.com>
Date: Fri Mar 31 15:19:10 2023 +1030
ubsan: aarch64 parse_vector_reg_list
tc-aarch64.c:1473:27: runtime error: left shift of 7 by 30 places
cannot be represented in type 'int'.
* config/tc-aarch64.c (parse_vector_reg_list): Avoid UB left
shift.
Diff:
---
gas/config/tc-aarch64.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 747cf37d4b8..99fb5de2679 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1393,7 +1393,7 @@ parse_vector_reg_list (char **ccp, aarch64_reg_type type,
char *str = *ccp;
int nb_regs;
struct vector_type_el typeinfo, typeinfo_first;
- int val, val_range, mask;
+ uint32_t val, val_range, mask;
int in_range;
int ret_val;
bool error = false;
@@ -1414,8 +1414,8 @@ parse_vector_reg_list (char **ccp, aarch64_reg_type type,
typeinfo_first.element_size = 0;
typeinfo_first.index = 0;
ret_val = 0;
- val = -1;
- val_range = -1;
+ val = -1u;
+ val_range = -1u;
in_range = 0;
mask = reg_type_mask (type);
do
@@ -1470,7 +1470,7 @@ parse_vector_reg_list (char **ccp, aarch64_reg_type type,
if (! error)
for (;;)
{
- ret_val |= val_range << (5 * nb_regs);
+ ret_val |= val_range << ((5 * nb_regs) & 31);
nb_regs++;
if (val_range == val)
break;
reply other threads:[~2023-04-02 22: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=20230402222434.8BDBD385800C@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).