We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 046d284 commit 182bf51Copy full SHA for 182bf51
rex/src/task_struct.rs
@@ -49,7 +49,11 @@ impl TaskStruct {
49
// a user-provided buffer, here we can take advantage of Rust's ownership by
50
// just providing a reference to the CString instead
51
pub fn get_comm(&self) -> Result<&CStr, ffi::FromBytesUntilNulError> {
52
- CStr::from_bytes_until_nul(&self.kptr.comm[..])
+ // casting from c_char to u8 is sound, see:
53
+ // https://doc.rust-lang.org/stable/src/core/ffi/c_str.rs.html#276-288
54
+ let comm_bytes =
55
+ unsafe { &*(&self.kptr.comm[..] as *const _ as *const [u8]) };
56
+ CStr::from_bytes_until_nul(comm_bytes)
57
}
58
59
pub fn get_pt_regs(&self) -> &'static PtRegs {
0 commit comments