Skip to content

Commit

Permalink
Avoids overflow in getRegisterName for TMS320C64x (capstone-engine#1375)
Browse files Browse the repository at this point in the history
* Avoids overflow in getRegisterName for TMS320C64x

* Revert "Avoids overflow in getRegisterName for TMS320C64x"

This reverts commit 18acee6.

* Checks register in DecodeMemOperandSc
  • Loading branch information
catenacyber authored and aquynh committed Feb 16, 2019
1 parent 0909305 commit 50123f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/TMS320C64x/TMS320C64xDisassembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ static DecodeStatus DecodeMemOperandSc(MCInst *Inst, unsigned Val,
else if((base >= TMS320C64X_REG_B0) && (base <= TMS320C64X_REG_B31))
base = (base - TMS320C64X_REG_B0 + TMS320C64X_REG_A0);
basereg = getReg(GPRegsDecoderTable, base);
if (basereg == ~0U)
return MCDisassembler_Fail;

switch(mode) {
case 0:
Expand All @@ -293,6 +295,8 @@ static DecodeStatus DecodeMemOperandSc(MCInst *Inst, unsigned Val,
else if((offset >= TMS320C64X_REG_B0) && (offset <= TMS320C64X_REG_B31))
offset = (offset - TMS320C64X_REG_B0 + TMS320C64X_REG_A0);
offsetreg = getReg(GPRegsDecoderTable, offset);
if (offsetreg == ~0U)
return MCDisassembler_Fail;
MCOperand_CreateImm0(Inst, (scaled << 19) | (basereg << 12) | (offsetreg << 5) | (mode << 1) | unit);
break;
default:
Expand Down

0 comments on commit 50123f1

Please sign in to comment.