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 BytesRefHash {
pub pool: *mut ByteBlockPool,
................................
}
impl BytesRefHash {
........................................
pub fn byte_pool(&self) -> &ByteBlockPool {
unsafe { &*self.pool }
}
fn pool_mut(&mut self) -> &mut ByteBlockPool {
unsafe { &mut *self.pool }
}
.......................................
}
Considering that pub mod core, BytesRefHash is pub struct and pool is a pub field, I assume that users can directly manipulate this field. This potential situation could result in self.pool being 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.
If there is no external using for BytesRefHash, maybe it should not be marked as pub, at least for its field should not be mark as pub.
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 core,BytesRefHashispubstruct andpoolis apubfield, I assume that users can directly manipulate this field. This potential situation could result inself.poolbeing 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.If there is no external using for BytesRefHash, maybe it should not be marked as pub, at least for its field should not be mark as pub.