There are multiple memory safety issues with the implementations of methods in CMutSlice that are marked safe, allowing aliased mutable references.
For example :
extern crate cslice;
use cslice::{CMutSlice};
fn main() {
let mut a : [i32; 5] = [1, 2, 3, 4, 5];
let mut sl = unsafe{CMutSlice::new(&mut a[0], 5)};
// Multiple mutable references to same location
let ptr1: &mut[i32] = sl.as_mut_slice();
let ptr2: &mut[i32] = sl.as_mut_slice();
ptr1[0] = 5;
println!("{:?}", ptr2); // ptr2 will have also changed
}
Similarly, one could exploit vulnerabilities in CMutSlice::as_ptr() and CMutSlice::clone (implicitly derived).
There are multiple memory safety issues with the implementations of methods in
CMutSlicethat are marked safe, allowing aliased mutable references.For example :
Similarly, one could exploit vulnerabilities in
CMutSlice::as_ptr()andCMutSlice::clone(implicitly derived).