Skip to content

Commit

Permalink
do not panic on negative compressed displacements, i mean it!!
Browse files Browse the repository at this point in the history
  • Loading branch information
iximeow committed Dec 17, 2021
1 parent 067c5f0 commit 2c33266
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shared/evex.in
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions test/long_mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
1 change: 1 addition & 0 deletions test/protected_mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
1 change: 1 addition & 0 deletions test/real_mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit 2c33266

Please sign in to comment.