From 12251de92baadedbecca2048740959b0f965ffc5 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 21 Mar 2021 11:40:56 -0700 Subject: fix potential successful decodes with Opcode::Invalid vmov* are.. somehow messed up too --- src/long_mode/mod.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/long_mode/mod.rs') diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index 2c4ac92..1e3f568 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -6516,12 +6516,6 @@ fn read_operands>(decoder: &InstDecoder, mut bytes_iter: T, // match operand_code { match operand_code.special_case_handler_index() { 0 => { - // turns out xed cand capstone both permit nonzero rrr bits here. - // if (modrm & 0b00111000) != 0 { - // instruction.opcode = Opcode::Invalid; - // return Err(DecodeError::InvalidOperand); - //} - instruction.operands[0] = mem_oper; instruction.operand_count = 1; }, @@ -8349,8 +8343,12 @@ fn unlikely_operands>(decoder: &InstDecoder, mut bytes_iter instruction.operands[0] = OperandSpec::Nothing; instruction.operand_count = 0; return Ok(()); + } else { + instruction.opcode = Opcode::Invalid; + instruction.operands[0] = OperandSpec::Nothing; + instruction.operand_count = 0; + return Err(DecodeError::InvalidOpcode); } - return Err(DecodeError::InvalidOpcode); } 0b010 => { if !instruction.prefixes.rep() || instruction.prefixes.repnz() { @@ -8365,6 +8363,11 @@ fn unlikely_operands>(decoder: &InstDecoder, mut bytes_iter instruction.opcode = Opcode::UIRET; instruction.operands[0] = OperandSpec::Nothing; instruction.operand_count = 0; + } else { + instruction.opcode = Opcode::Invalid; + instruction.operands[0] = OperandSpec::Nothing; + instruction.operand_count = 0; + return Err(DecodeError::InvalidOpcode); } } 0b101 => { @@ -8372,6 +8375,11 @@ fn unlikely_operands>(decoder: &InstDecoder, mut bytes_iter instruction.opcode = Opcode::TESTUI; instruction.operands[0] = OperandSpec::Nothing; instruction.operand_count = 0; + } else { + instruction.opcode = Opcode::Invalid; + instruction.operands[0] = OperandSpec::Nothing; + instruction.operand_count = 0; + return Err(DecodeError::InvalidOpcode); } } 0b110 => { -- cgit v1.1