Skip to content

Commit

Permalink
target-i386: cpu: Fix potential buffer overrun in get_register_name_32()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: liguang <[email protected]>
Reviewed by: Jesse Larrew <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
Igor Mammedov authored and afaerber committed Jun 10, 2013
1 parent 6b11322 commit 31ccdde
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion target-i386/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 31ccdde

Please sign in to comment.