aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2019-10-29 10:25:09 +0000
committerNick Clifton <nickc@redhat.com>2019-10-29 10:25:09 +0000
commit9adb25915092daa4096911d04fadb5d496c926a6 (patch)
treedfc49676fa42e8825bd2b449eb735a97f14abf66
parent993a00a986d0795a3cbb7a2dd0c640d8e6d66734 (diff)
downloadgdb-9adb25915092daa4096911d04fadb5d496c926a6.zip
gdb-9adb25915092daa4096911d04fadb5d496c926a6.tar.gz
gdb-9adb25915092daa4096911d04fadb5d496c926a6.tar.bz2
Fix a potential illegal array access in the D30V disassembler.
* d30v-dis.c (print_insn): Check that operand index is valid before attempting to access the operands array.
-rw-r--r--opcodes/ChangeLog5
-rw-r--r--opcodes/d30v-dis.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d596729..ae2e00c 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,10 @@
2019-10-29 Nick Clifton <nickc@redhat.com>
+ * d30v-dis.c (print_insn): Check that operand index is valid
+ before attempting to access the operands array.
+
+2019-10-29 Nick Clifton <nickc@redhat.com>
+
* ia64-opc.c (locate_opcode_ent): Prevent a negative shift when
locating the bit to be tested.
diff --git a/opcodes/d30v-dis.c b/opcodes/d30v-dis.c
index 2861ca5..8dd43fb 100644
--- a/opcodes/d30v-dis.c
+++ b/opcodes/d30v-dis.c
@@ -23,6 +23,7 @@
#include "opcode/d30v.h"
#include "disassemble.h"
#include "opintl.h"
+#include "libiberty.h"
#define PC_MASK 0xFFFFFFFF
@@ -313,7 +314,9 @@ print_insn (struct disassemble_info *info,
(*info->fprintf_func) (info->stream, "0x%x", val);
}
/* If there is another operand, then write a comma and space. */
- if (insn->form->operands[opind] && !(found_control && opind == 2))
+ if (opind < (int) ARRAY_SIZE (insn->form->operands)
+ && insn->form->operands[opind]
+ && !(found_control && opind == 2))
need_comma = 1;
}
if (need_paren)