aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-29 10:46:59 +0930
committerAlan Modra <amodra@gmail.com>2020-08-29 13:17:13 +0930
commit8a267ea84798eb4e6547c8ff2617d2377d83c118 (patch)
tree66d3527e419c4b19677c88b1ad1f63c93e46a5c4 /gas
parent736c9875c040e88c5f508338b68f04f7a42c3b9d (diff)
downloadgdb-8a267ea84798eb4e6547c8ff2617d2377d83c118.zip
gdb-8a267ea84798eb4e6547c8ff2617d2377d83c118.tar.gz
gdb-8a267ea84798eb4e6547c8ff2617d2377d83c118.tar.bz2
PR26481 UBSAN: tc-pj.c:281 index out of bounds
PR 26481 * config/tc-pj.c (md_assemble): Don't loop past end of opcode->arg array.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-pj.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 9bdbb4b..210a22c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2020-08-29 Alan Modra <amodra@gmail.com>
+
+ PR 26481
+ * config/tc-pj.c (md_assemble): Don't loop past end of
+ opcode->arg array.
+
2020-08-28 Alan Modra <amodra@gmail.com>
PR 26460
diff --git a/gas/config/tc-pj.c b/gas/config/tc-pj.c
index bc4b8cb..1ec8454 100644
--- a/gas/config/tc-pj.c
+++ b/gas/config/tc-pj.c
@@ -270,7 +270,7 @@ md_assemble (char *str)
}
else
{
- int an;
+ unsigned int an;
output = frag_more (opcode->len);
output[idx++] = opcode->opcode;
@@ -278,7 +278,7 @@ md_assemble (char *str)
if (opcode->opcode_next != -1)
output[idx++] = opcode->opcode_next;
- for (an = 0; opcode->arg[an]; an++)
+ for (an = 0; an < ARRAY_SIZE (opcode->arg) && opcode->arg[an]; an++)
{
expressionS arg;