aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-12-17 10:45:31 -0800
committeriximeow <me@iximeow.net>2021-12-17 10:46:21 -0800
commit2c332661b5ccf116a468e1e23711017d77c1531a (patch)
treecdbd90a0f932ffaaee48904b5309be9c2574d3d8
parent067c5f08dea7c1d3b70a7c38259b8db2c301d89f (diff)
do not panic on negative compressed displacements, i mean it!!
-rw-r--r--src/shared/evex.in2
-rw-r--r--test/long_mode/mod.rs1
-rw-r--r--test/protected_mode/mod.rs1
-rw-r--r--test/real_mode/mod.rs1
4 files changed, 4 insertions, 1 deletions
diff --git a/src/shared/evex.in b/src/shared/evex.in
index 414074e..5d3b053 100644
--- a/src/shared/evex.in
+++ b/src/shared/evex.in
@@ -238,7 +238,7 @@ pub(crate) fn read_evex<
_ => None
};
if let Some(size) = overridden_size {
- instruction.disp *= size;
+ instruction.disp = instruction.disp.wrapping_mul(size);
} else {
apply_disp_scale(instruction);
}
diff --git a/test/long_mode/mod.rs b/test/long_mode/mod.rs
index ee0ab4e..d23df49 100644
--- a/test/long_mode/mod.rs
+++ b/test/long_mode/mod.rs
@@ -3395,4 +3395,5 @@ fn from_llvm() {
fn from_reports() {
// negative compressed evex displacements should not overflow and panic
test_display(&[0x62, 0xf2, 0x6d, 0xac, 0x00, 0x59, 0xa7], "vpshufb ymm3{k4}{z}, ymm2, ymmword [rcx - 0xb20]");
+ test_display(&[0x62, 0xf2, 0xfd, 0x0f, 0x8a, 0x62, 0xf2], "vcompresspd xmmword [rdx - 0x70]{k7}, xmm4");
}
diff --git a/test/protected_mode/mod.rs b/test/protected_mode/mod.rs
index 70dfb78..1b0ca59 100644
--- a/test/protected_mode/mod.rs
+++ b/test/protected_mode/mod.rs
@@ -3082,4 +3082,5 @@ fn from_llvm() {
fn from_reports() {
// negative compressed evex displacements should not overflow and panic
test_display(&[0x62, 0xf2, 0x6d, 0xac, 0x00, 0x59, 0xa7], "vpshufb ymm3{k4}{z}, ymm2, ymmword [ecx - 0xb20]");
+ test_display(&[0x62, 0xf2, 0xfd, 0x0f, 0x8a, 0x62, 0xf2], "vcompresspd xmmword [edx - 0x70]{k7}, xmm4");
}
diff --git a/test/real_mode/mod.rs b/test/real_mode/mod.rs
index b13358a..b2d6d8d 100644
--- a/test/real_mode/mod.rs
+++ b/test/real_mode/mod.rs
@@ -18367,4 +18367,5 @@ fn test_invalid_sequences() {
fn from_reports() {
// negative compressed evex displacements should not overflow and panic
test_display(&[0x62, 0xf2, 0x6d, 0xac, 0x00, 0x59, 0xa7], "vpshufb ymm3{k4}{z}, ymm2, ymmword [bx + di - 0xb20]");
+ test_display(&[0x62, 0xf2, 0xfd, 0x0f, 0x8a, 0x62, 0xf2], "vcompresspd xmmword [bp + si - 0x70]{k7}, xmm4");
}