From 1683b7af689b021946d1d869bf32ad95934639f2 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 2 Aug 2020 21:20:27 -0700 Subject: correctly handle some more invalid opcode scenarios --- src/long_mode/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index ef7f8c9..18b9f7b 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -5643,6 +5643,9 @@ fn read_instr>(decoder: &InstDecoder, mut bytes_iter: T, in } else { unsafe { unreachable_unchecked(); } } + if instruction.opcode == Opcode::Invalid && record.1 == OperandCode::Nothing { + return Err(DecodeError::InvalidOpcode); + } instruction.prefixes = prefixes; read_operands(decoder, bytes_iter, instruction, record.1, &mut length)?; instruction.length = length; @@ -8336,6 +8339,9 @@ fn decode_x87>(_decoder: &InstDecoder, mut bytes_iter: T, i } }; instruction.opcode = opcode; + if instruction.opcode == Opcode::Invalid { + return Err(DecodeError::InvalidOpcode); + } // TODO: support 80-bit operands match x87_operands { OperandCodeX87::Est => { -- cgit v1.1