ubsan: arm-dis.c index out of bounds

Alan Modra amodra@gmail.com
Wed Sep 14 00:39:19 GMT 2022


We are way off in the weeds with this one, and will be printing
<UNPREDICTABLE> for S > 10, so I think wrapping the register number is
fine.  Found by fuzzers.

	* arm-dis.c (print_insn_cde): Wrap 'T' value.

diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index c1bf276b423..684c74f7f20 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -8957,7 +8957,7 @@ print_insn_cde (struct disassemble_info *info, long given, bool thumb)
 		    break;
 
 		  case 'T':
-		    func (stream, "%s", arm_regnames[value + 1]);
+		    func (stream, "%s", arm_regnames[(value + 1) & 15]);
 		    break;
 
 		  case 'd':

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list