x86: fix Out-of-bounds read error in is16BitEquivalent(). issue reported by Coverity

This commit is contained in:
Nguyen Anh Quynh 2014-10-01 14:35:29 +08:00
parent 9bf1b87a66
commit c96f1b06b2
3 changed files with 4 additions and 8 deletions

View File

@ -1342,9 +1342,6 @@ static void printMemExtend(MCInst *MI, unsigned OpNum, SStream *O, char SrcRegKi
case 'w': case 'w':
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTW; MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTW;
break; break;
case 'x':
MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].ext = ARM64_EXT_UXTX;
break;
} }
} else { } else {
switch(SrcRegKind) { switch(SrcRegKind) {

View File

@ -468,7 +468,7 @@ static DecodeStatus DecodeINSVE_DF_4(MCInst *MI, uint32_t insn,
//assert(NSize != 0 && RegDecoder != nullptr); //assert(NSize != 0 && RegDecoder != nullptr);
if (RegDecoder == NULL) if (RegDecoder == NULL)
return; return MCDisassembler_Fail;
// $wd // $wd
tmp = fieldFromInstruction(insn, 6, 5); tmp = fieldFromInstruction(insn, 6, 5);

View File

@ -959,14 +959,13 @@ static bool is16BitEquivalent(unsigned orig, unsigned equiv)
size_t i; size_t i;
uint16_t idx; uint16_t idx;
if ((idx = x86_16_bit_eq_lookup[orig]) != 0) if ((idx = x86_16_bit_eq_lookup[orig]) != 0) {
{ for (i = idx - 1; i < ARR_SIZE(x86_16_bit_eq_tbl) && x86_16_bit_eq_tbl[i].first == orig; i++) {
for (i = idx - 1; x86_16_bit_eq_tbl[i].first == orig && i < ARR_SIZE(x86_16_bit_eq_tbl); ++i)
{
if (x86_16_bit_eq_tbl[i].second == equiv) if (x86_16_bit_eq_tbl[i].second == equiv)
return true; return true;
} }
} }
return false; return false;
} }