You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
pub struct Cursor<'a> {
cursor: sys::ecs_meta_cursor_t,
phantom: std::marker::PhantomData<&'a ()>,
}
impl<'a> Cursor<'a> {
/// Creates a new cursor instance
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn new(
world: impl WorldProvider<'a>,
type_id: impl Into<Entity>,
ptr: *mut std::ffi::c_void,
) -> Self {
let world = world.world_ptr();
let type_id = *type_id.into();
let cursor = unsafe { sys::ecs_meta_cursor(world, type_id, ptr) };
Self {
cursor,
phantom: std::marker::PhantomData,
}
}
Considering that pub mod addons, and new is also a pub function. I assume that users can directly call this function. This potential situation could result in sys::ecs_meta_cursor(world, type_id, ptr) operating on a null pointer, and directly dereferencing it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.
I suggest Several possible fixes:
If there is no external usage for Cursor or new, they should not marked as pub, at least its new should not marked as pub
new method should add additional check for null pointer.
mark new method as unsafe and proper doc to let users know that they should provide valid Pointers.
The text was updated successfully, but these errors were encountered:
Hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
Considering that
pub mod addons
, andnew
is also a pub function. I assume that users can directly call this function. This potential situation could result insys::ecs_meta_cursor(world, type_id, ptr)
operating on a null pointer, and directly dereferencing it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.I suggest Several possible fixes:
Cursor
ornew
, they should not marked aspub
, at least itsnew
should not marked aspub
new
method should add additional check for null pointer.The text was updated successfully, but these errors were encountered: