Commit: Fix potential undefined behaviour in RX disassembler

Message ID 87zhho275n.fsf@redhat.com
State New
Headers show
Series
  • Commit: Fix potential undefined behaviour in RX disassembler
Related show

Commit Message

Nick Clifton Oct. 25, 2019, 3:09 p.m.
Hi Guys,

  I am applying the patch below to fix a problem detected by the
  undefined behaviour sanitizer.  The address calculation has the
  potential to be undefined since "opcode.op + *s" is beyond the end
  of the opcode.op array.

Cheers
  Nick

opcodes/ChangeLog
2019-10-25  Nick Clifton  <nickc@redhat.com>

	* rx-dis.c (print_insn_rx): Use parenthesis to ensure correct
	access to opcodes.op array element.

c

Patch

diff --git a/opcodes/rx-dis.c b/opcodes/rx-dis.c
index c84f7c5d60..80144bb612 100644
--- a/opcodes/rx-dis.c
+++ b/opcodes/rx-dis.c
@@ -319,7 +319,7 @@  print_insn_rx (bfd_vma addr, disassemble_info * dis)
            case '0':
            case '1':
            case '2':
-             oper = opcode.op + *s - '0';
+             oper = opcode.op + (*s - '0');
              if (do_size)
                {
                  if (oper->type == RX_Operand_Indirect || oper->type == RX_Operand_Zero_Indirect)