From c683f1b93444a25e093225751c597dccc2082f8e Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Mon, 3 Jun 2013 18:23:27 +0200 Subject: [PATCH] target-i386: cpu: Fix potential buffer overrun in get_register_name_32() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Spotted by Coverity, x86_reg_info_32[] is CPU_NB_REGS32 elements long, so accessing x86_reg_info_32[CPU_NB_REGS32] will be one element off array. Signed-off-by: Igor Mammedov Reviewed-by: liguang Reviewed by: Jesse Larrew Signed-off-by: Andreas Färber (cherry picked from commit 31ccdde298d98b08526dc23059071c9086dec6c2) Signed-off-by: Michael Roth --- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 1a501d9d3..ae8e68271 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -221,7 +221,7 @@ X86RegisterInfo32 x86_reg_info_32[CPU_NB_REGS32] = { const char *get_register_name_32(unsigned int reg) { - if (reg > CPU_NB_REGS32) { + if (reg >= CPU_NB_REGS32) { return NULL; } return x86_reg_info_32[reg].name; -- 2.39.2