Fix potential array out of bounds

This commit is contained in:
Johan Mattsson 2022-11-26 15:59:18 +01:00
parent bb358745c6
commit 313ce264ac
2 changed files with 4 additions and 4 deletions

View File

@ -73,7 +73,7 @@ static DecodeStatus DecodeGPRRegisterClass(MCInst *Inst, uint64_t RegNo,
{
unsigned Reg = 0;
if (RegNo > sizeof(GPRDecoderTable))
if (RegNo >= ARR_SIZE(GPRDecoderTable))
return MCDisassembler_Fail;
// We must define our own mapping from RegNo to register identifier.
@ -101,7 +101,7 @@ static DecodeStatus DecodeFPR32RegisterClass(MCInst *Inst, uint64_t RegNo,
{
unsigned Reg = 0;
if (RegNo > sizeof(FPR32DecoderTable))
if (RegNo >= ARR_SIZE(FPR32DecoderTable))
return MCDisassembler_Fail;
// We must define our own mapping from RegNo to register identifier.
@ -141,7 +141,7 @@ static DecodeStatus DecodeFPR64RegisterClass(MCInst *Inst, uint64_t RegNo,
{
unsigned Reg = 0;
if (RegNo > sizeof(FPR64DecoderTable))
if (RegNo >= ARR_SIZE(FPR64DecoderTable))
return MCDisassembler_Fail;
// We must define our own mapping from RegNo to register identifier.

View File

@ -1898,7 +1898,7 @@ const char *TMS320C64x_group_name(csh handle, unsigned int id)
#ifndef CAPSTONE_DIET
unsigned int i;
if (id >= TMS320C64X_GRP_ENDING)
if (id >= ARR_SIZE(group_name_maps))
return NULL;
for (i = 0; i < ARR_SIZE(group_name_maps); i++) {