[binutils-gdb] ubsan: arm: out of bounds array access

Alan Modra amodra@sourceware.org
Mon Jan 20 09:54:00 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2bddb71a7421213dd9d8b8f2db133b43f5e1357e

commit 2bddb71a7421213dd9d8b8f2db133b43f5e1357e
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Jan 20 12:31:58 2020 +1030

    ubsan: arm: out of bounds array access
    
     .inst 0x81bdfe9f
    
    disassembles as
       0:	81bdfe9f 	ldaexdhi	pc, reg-names-std, [sp]
    
    I'm quite sure "reg-names-std" isn't an ARM register.
    
    	* arm-dis.c (print_insn_arm): Wrap 'T' value.

Diff:
---
 opcodes/ChangeLog | 4 ++++
 opcodes/arm-dis.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 1f71751..04eaa86 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,7 @@
+2020-01-20  Alan Modra  <amodra@gmail.com>
+
+	* arm-dis.c (print_insn_arm): Wrap 'T' value.
+
 2020-01-18  Nick Clifton  <nickc@redhat.com>
 
 	* configure: Regenerate.
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index c986b58..be2a932 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -10106,7 +10106,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info, long given)
 			  case 'T':
 			    /* We want register + 1 when decoding T.  */
 			    if (*c == 'T')
-			      ++value;
+			      value = (value + 1) & 0xf;
 
 			    if (c[1] == 'u')
 			      {



More information about the Binutils-cvs mailing list