kvx: fix kvx_reassemble_bundle index 8 out of bounds
authorPaul Iannetta <piannetta@kalrayinc.com>
Thu, 24 Aug 2023 08:39:14 +0000 (10:39 +0200)
committerAlan Modra <amodra@gmail.com>
Thu, 24 Aug 2023 10:33:23 +0000 (20:03 +0930)
opcodes/
* kvx-dis.c (print_insn_kvx): Change the loop condition so that
wordcount is always less than KVXMAXBUNDLEWORDS.
(decode_prologue_epilogue_bundle): Likewise.

opcodes/kvx-dis.c

index 7fef4c7543d8c5e4a4702c96840ccd7a64341073..ec9c7718b06ea9fafeaa06b229fdc2c0be2cc123 100644 (file)
@@ -1056,7 +1056,7 @@ print_insn_kvx (bfd_vma memaddr, struct disassemble_info *info)
          wordcount++;
        }
       while (kvx_has_parallel_bit (bundle_words[wordcount - 1])
-            && wordcount < KVXMAXBUNDLEWORDS);
+            && wordcount < KVXMAXBUNDLEWORDS - 1);
       invalid_bundle = kvx_reassemble_bundle (wordcount, &insncount);
     }
 
@@ -1238,7 +1238,7 @@ decode_prologue_epilogue_bundle (bfd_vma memaddr,
       nb_syl++;
     }
   while (kvx_has_parallel_bit (bundle_words[nb_syl - 1])
-        && nb_syl < KVXMAXBUNDLEWORDS);
+        && nb_syl < KVXMAXBUNDLEWORDS - 1);
   if (kvx_reassemble_bundle (nb_syl, &nb_insn))
     return -1;