This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Commit: Fix potential undefined behaviour in RX disassembler


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.

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)
c


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]