[libos] Fix readlinkat with non-positive bufsize

This commit is contained in:
ClawSeven 2024-01-29 15:49:39 +08:00 committed by volcano
parent c2296c13d2
commit e9f2c09012

@ -559,6 +559,9 @@ pub fn do_readlinkat(dirfd: i32, path: *const i8, buf: *mut u8, size: usize) ->
.to_string_lossy() .to_string_lossy()
.into_owned(); .into_owned();
let buf = { let buf = {
if size == 0 {
return_errno!(EINVAL, "bufsiz is not a positive number");
}
from_user::check_array(buf, size)?; from_user::check_array(buf, size)?;
unsafe { std::slice::from_raw_parts_mut(buf, size) } unsafe { std::slice::from_raw_parts_mut(buf, size) }
}; };