target-i386: cpu: fix potential buffer overrun in get_register_name_32()
PATCH 1/1 target-i386: cpu: fix potential buffer overrun in get_register_name_32()
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.
--- target-i386/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-i386/cpu.c +1 -1
@@ -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;
Signature · 1 line
1.7.1
Quoted 15 lines · Igor Mammedov
spotted by Coverity,
x86_reg_info_32[] isCPU_NB_REGS32elements long, so accessing x86_reg_info_32[CPU_NB_REGS32] will be one element off array.Signed-off-by Igor Mammedov <[email protected]>--- target-i386/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)target-i386/cpu.c +0
-0
target-i386/cpu.c X86RegisterInfo32 x86_reg_info_32[CPU_NB_REGS32] = { · line 227
Quoted 8 lines
target-i386/cpu.c +1
-1@@ -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;
Looks obvious now that it's been spotted. ;)
Reviewed by: Jesse Larrew <[email protected]>
Jesse Larrew
Software Engineer, KVM Team
IBM Linux Technology Center
Phone: (512) 973-2052 (T/L: 363-2052)
[email protected]
Quoted 3 lines · 在 2013-06-03一的 18:23 +0200,Igor Mammedov写道:
spotted by Coverity,
x86_reg_info_32[] isCPU_NB_REGS32elements long, so accessing x86_reg_info_32[CPU_NB_REGS32] will be one element off array.
Yes, it will.
Quoted 19 lines
Signed-off-by Igor Mammedov <[email protected]>--- target-i386/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)target-i386/cpu.c +1
-1@@ -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;
Andreas Färber
AppliedAm 03.06.2013 18:23, schrieb Igor Mammedov:
Quoted 8 lines
spotted by Coverity,
x86_reg_info_32[] isCPU_NB_REGS32elements long, so accessing x86_reg_info_32[CPU_NB_REGS32] will be one element off array.Signed-off-by Igor Mammedov <[email protected]>--- target-i386/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg