Skip to content

Commit

Permalink
Merge pull request #422 from Egggggg/master
Browse files Browse the repository at this point in the history
Change Star::write() to use checked subtractions
  • Loading branch information
Freax13 committed Jun 11, 2023
2 parents 22066fa + 3222b10 commit 486c2a4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/registers/model_specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,25 @@ mod x86_64 {
cs_syscall: SegmentSelector,
ss_syscall: SegmentSelector,
) -> Result<(), &'static str> {
if cs_sysret.0 - 16 != ss_sysret.0 - 8 {
let cs_sysret_cmp = cs_sysret
.0
.checked_sub(16)
.ok_or("Sysret CS is not at least 16.")?;
let ss_sysret_cmp = ss_sysret
.0
.checked_sub(8)
.ok_or("Sysret SS is not at least 8.")?;
let cs_syscall_cmp = cs_syscall.0;
let ss_syscall_cmp = ss_syscall
.0
.checked_sub(8)
.ok_or("Syscall SS is not at least 8.")?;

if cs_sysret_cmp != ss_sysret_cmp {
return Err("Sysret CS and SS is not offset by 8.");
}

if cs_syscall.0 != ss_syscall.0 - 8 {
if cs_syscall_cmp != ss_syscall_cmp {
return Err("Syscall CS and SS is not offset by 8.");
}

Expand Down

0 comments on commit 486c2a4

Please sign in to comment.