Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential array out of bounds #1938

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions arch/RISCV/RISCVDisassembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion arch/TMS320C64x/TMS320C64xMapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down