Fix #27: bool on kernel is 4 bytes, while rust's is 1 byte. This causes the stack to be covered, triggering a ub.

This commit is contained in:
Nullptr
2023-06-13 23:32:43 +08:00
parent bea5ed47b8
commit 7c27c32861

View File

@@ -25,13 +25,13 @@ pub fn get_kernel_su() -> Option<Version> {
}
pub fn uid_granted_root(uid: i32) -> bool {
let mut granted = false;
unsafe { prctl(KERNEL_SU_OPTION, CMD_UID_GRANTED_ROOT, uid, &mut granted as *mut bool) };
granted
let mut granted = 0;
unsafe { prctl(KERNEL_SU_OPTION, CMD_UID_GRANTED_ROOT, uid, &mut granted as *mut i32) };
granted == 1
}
pub fn uid_should_umount(uid: i32) -> bool {
let mut umount = false;
unsafe { prctl(KERNEL_SU_OPTION, CMD_UID_SHOULD_UMOUNT, uid, &mut umount as *mut bool) };
umount
let mut umount = 0;
unsafe { prctl(KERNEL_SU_OPTION, CMD_UID_SHOULD_UMOUNT, uid, &mut umount as *mut i32) };
umount == 1
}