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 read_data(data: &mut Vec<i64>, encoded_data: &[u8], index: &mut usize) {
let length = data.len();
if length > 0 {
data.clear();
let ptr = encoded_data[*index..].as_ptr() as *mut i64;
let v = unsafe { Vec::from_raw_parts(ptr, length, length) };
let _ = v.iter().map(|&x| data.push(x)).collect::<()>();
v.into_raw_parts();
*index += length << 3;
}
}
This is because it converts a pointer of type 'u8' to a pointer of type 'i64', which requires 8-byte alignment, while a pointer of type 'u8' does not guarantee this alignment. This can result in undefined behavior (UB).
Hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
This is because it converts a pointer of type 'u8' to a pointer of type 'i64', which requires 8-byte alignment, while a pointer of type 'u8' does not guarantee this alignment. This can result in undefined behavior (UB).