Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Star::write() to use checked subtractions #422

Merged
merged 2 commits into from
Jun 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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