ASSERT invalid division in decode_modrm
Created by: dvyukov
While fuzzing decoder on commit e85c2eff I've got the following error:
core/ir/x86/decode.c:1758:36: runtime error: division of -2147483648 by -1 cannot be represented in type 'int'
#0 0x56423d93a195 in decode_modrm core/ir/x86/decode.c:1758:36
#1 0x56423d9378b9 in decode_operand core/ir/x86/decode.c
#2 0x56423d9335a3 in decode_common core/ir/x86/decode.c:2574:18
#3 0x56423d932d66 in decode core/ir/x86/decode.c:2695:12
The input was 62 03 a5 62 03 a5 00 00 00 80 00 00 00 00 00 00
.
I think we need something like:
--- a/core/ir/x86/decode.c
+++ b/core/ir/x86/decode.c
@@ -1755,6 +1755,8 @@ decode_modrm(decode_info_t *di, byte opt
int compressed_disp_scale = 0;
if (di->evex_encoded) {
compressed_disp_scale = decode_get_compressed_disp_scale(di);
+ if (compressed_disp_scale == -1)
+ return false;
needs_full_disp = disp % compressed_disp_scale != 0;
}
force_full_disp = !needs_full_disp && di->has_disp && disp >= INT8_MIN &&