-
Notifications
You must be signed in to change notification settings - Fork 338
Open
Description
hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
pub fn create_rmstring(
ctx: *mut rawmod::RedisModuleCtx,
from_str: &str,
str: *mut *mut rawmod::RedisModuleString,
) -> c_int {
if let Ok(s) = CString::new(from_str) {
let p = s.as_bytes_with_nul().as_ptr().cast::<c_char>();
let len = s.as_bytes().len();
unsafe { *str = rawmod::RedisModule_CreateString.unwrap()(ctx, p, len) };
return Status::Ok as c_int;
}
Status::Err as c_int
}
Considering pub mod c_api and this is a pub function, I assume user can directly call to this function, if it's this case , I think there may exist a unsound problem in this code, eg. maybe str is null? It will lead to UB. I suggest mark this function as unsafe or add additional check to varify the pointer. I chose to report this issue for security reasons, but don't mind if the function is not intended for external use and should be marked as pub(crate), or if this is an error report and there is actually no unsound problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels