mirror of
https://github.com/mii443/rsrv.git
synced 2025-08-22 16:35:27 +00:00
fix overflow
This commit is contained in:
@ -43,24 +43,24 @@ pub struct RV {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn rv_load_cb(user: *mut c_void, addr: u32, data: *mut u8) -> u32 {
|
extern "C" fn rv_load_cb(user: *mut c_void, addr: u32, data: *mut u8) -> u32 {
|
||||||
if (addr - 0x80000000) > 0x10000 {
|
if (addr.wrapping_sub(0x80000000)) > 0x10000 {
|
||||||
return RV_BAD;
|
return RV_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
*data = *(user.offset((addr - 0x80000000) as isize) as *mut u8);
|
*data = *(user.offset((addr.wrapping_sub(0x80000000)) as isize) as *mut u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
RV_OK
|
RV_OK
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn rv_store_cb(user: *mut c_void, addr: u32, data: u8) -> u32 {
|
extern "C" fn rv_store_cb(user: *mut c_void, addr: u32, data: u8) -> u32 {
|
||||||
if (addr - 0x80000000) > 0x10000 {
|
if (addr.wrapping_sub(0x80000000)) > 0x10000 {
|
||||||
return RV_BAD;
|
return RV_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
*(user.offset((addr - 0x80000000) as isize) as *mut u8) = data;
|
*(user.offset((addr.wrapping_sub(0x80000000)) as isize) as *mut u8) = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
RV_OK
|
RV_OK
|
||||||
|
Reference in New Issue
Block a user