instrs: Enforce memory for VSIB encodings

This commit is contained in:
Alexis Engelke
2020-07-02 09:47:55 +02:00
parent 141680e77c
commit c9333ac2c9
2 changed files with 12 additions and 12 deletions

View File

@@ -198,10 +198,6 @@ decode_modrm(const uint8_t* buffer, int len, DecodeMode mode, FdInstr* instr,
uint8_t mod_reg = (modrm & 0x38) >> 3;
uint8_t rm = modrm & 0x07;
// VSIB must have a memory operand with SIB byte.
if (UNLIKELY(vsib) && (rm != 4 || mod == 3))
return FD_ERR_UD;
bool is_seg = UNLIKELY(instr->type == FDI_MOV_G2S || instr->type == FDI_MOV_S2G);
bool is_cr = UNLIKELY(instr->type == FDI_MOV_CR);
bool is_dr = UNLIKELY(instr->type == FDI_MOV_DR);
@@ -249,6 +245,10 @@ decode_modrm(const uint8_t* buffer, int len, DecodeMode mode, FdInstr* instr,
return off;
}
// VSIB must have a memory operand with SIB byte.
if (UNLIKELY(vsib) && rm != 4)
return FD_ERR_UD;
// SIB byte
uint8_t scale = 0;
uint8_t idx = 4;