radare2/shlr/capstone-patches/fix-m68k-oob.patch
2018-07-16 09:43:33 +02:00

25 lines
702 B
Diff

diff --git a/arch/M68K/M68KInstPrinter.c b/arch/M68K/M68KInstPrinter.c
index 14a86e4..d826283 100644
--- a/arch/M68K/M68KInstPrinter.c
+++ b/arch/M68K/M68KInstPrinter.c
@@ -28,7 +28,8 @@
#ifndef CAPSTONE_DIET
static const char* s_spacing = " ";
-static const char* s_reg_names[] = {
+#define S_REG_NAMES_COUNT 47
+static const char* s_reg_names[S_REG_NAMES_COUNT] = {
"invalid",
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
@@ -338,6 +339,9 @@ const char* M68K_reg_name(csh handle, unsigned int reg)
#ifdef CAPSTONE_DIET
return NULL;
#else
+ if (reg >= S_REG_NAMES_COUNT) {
+ return NULL;
+ }
return s_reg_names[(int)reg];
#endif
}