Merge branch 'aya-rs:main' into main

pull/530/head
qjerome 2 years ago committed by GitHub
commit 07db8ee972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -419,7 +419,7 @@ pub unsafe fn bpf_probe_read_user_str_bytes(
dest.len() as u32, dest.len() as u32,
src as *const c_void, src as *const c_void,
); );
if len < 0 { if len <= 0 {
return Err(-1); return Err(-1);
} }
@ -430,7 +430,8 @@ pub unsafe fn bpf_probe_read_user_str_bytes(
return Err(-1); return Err(-1);
} }
Ok(&dest[..len]) // len includes NULL byte
Ok(&dest[..len - 1])
} }
/// Read a null-terminated string from _kernel space_ stored at `src` into `dest`. /// Read a null-terminated string from _kernel space_ stored at `src` into `dest`.
@ -571,7 +572,7 @@ pub unsafe fn bpf_probe_read_kernel_str_bytes(
dest.len() as u32, dest.len() as u32,
src as *const c_void, src as *const c_void,
); );
if len < 0 { if len <= 0 {
return Err(-1); return Err(-1);
} }
@ -582,7 +583,8 @@ pub unsafe fn bpf_probe_read_kernel_str_bytes(
return Err(-1); return Err(-1);
} }
Ok(&dest[..len]) // len includes NULL byte
Ok(&dest[..len - 1])
} }
/// Write bytes to the _user space_ pointer `src` and store them as a `T`. /// Write bytes to the _user space_ pointer `src` and store them as a `T`.

Loading…
Cancel
Save