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

Inappropriate inner unsafe #1

Open
charlesxsh opened this issue Dec 4, 2024 · 0 comments
Open

Inappropriate inner unsafe #1

charlesxsh opened this issue Dec 4, 2024 · 0 comments

Comments

@charlesxsh
Copy link

pub fn get_pointer_address(base_address: usize, address: usize, offsets: Vec<usize>) -> usize {
let mut addr =
unsafe { *((base_address as usize + address) as *const usize) + offsets[0] } as *mut c_void; // BINGO
for i in 1..offsets.len() {
addr = unsafe { *((addr) as *const usize) + offsets[i] } as *mut c_void;
}
return addr as usize;
}

The inner unsafe block in this public function might allow the user to cause memory issues like null-pointer dereference and use-after-free without touching unsafe blocks. It would be great to mark it as unsafe or add another check to notify the user of the severity/prevent memory issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant