ppc: fix registers overflow (#1687)
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22236
This commit is contained in:
parent
c59d62f735
commit
71f5c64c43
|
@ -164,9 +164,11 @@ static uint64_t getFeatureBits(int feature)
|
|||
}
|
||||
|
||||
static DecodeStatus decodeRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
const unsigned *Regs)
|
||||
const unsigned *Regs, size_t RegsLen)
|
||||
{
|
||||
// assert(RegNo < N && "Invalid register number");
|
||||
if (RegNo >= RegsLen / sizeof(unsigned)) {
|
||||
return MCDisassembler_Fail;
|
||||
}
|
||||
MCOperand_CreateReg0(Inst, Regs[RegNo]);
|
||||
return MCDisassembler_Success;
|
||||
}
|
||||
|
@ -175,70 +177,70 @@ static DecodeStatus DecodeCRRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
|||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, CRRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, CRRegs, sizeof(CRRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeCRBITRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, CRBITRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, CRBITRegs, sizeof(CRBITRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeF4RCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, FRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, FRegs, sizeof(FRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeF8RCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, FRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, FRegs, sizeof(FRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeVRRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, VRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, VRegs, sizeof(VRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeVSRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, VSRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, VSRegs, sizeof(VSRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeVSFRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, VSFRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, VSFRegs, sizeof(VSFRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeGPRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, GPRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, GPRegs, sizeof(GPRegs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeGPRC_NOR0RegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, GP0Regs);
|
||||
return decodeRegisterClass(Inst, RegNo, GP0Regs, sizeof(GP0Regs));
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeG8RCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, G8Regs);
|
||||
return decodeRegisterClass(Inst, RegNo, G8Regs, sizeof(G8Regs));
|
||||
}
|
||||
|
||||
#define DecodePointerLikeRegClass0 DecodeGPRCRegisterClass
|
||||
|
@ -248,7 +250,7 @@ static DecodeStatus DecodeQFRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
|||
uint64_t Address,
|
||||
const void *Decoder)
|
||||
{
|
||||
return decodeRegisterClass(Inst, RegNo, QFRegs);
|
||||
return decodeRegisterClass(Inst, RegNo, QFRegs, sizeof(QFRegs));
|
||||
}
|
||||
|
||||
#define DecodeQSRCRegisterClass DecodeQFRCRegisterClass
|
||||
|
|
Loading…
Reference in New Issue