Revert "ANDROID: ashmem: use strncpy_from_user in set_name"
This reverts commit ba971cd36a.
Bug: 414339114
Change-Id: If44d5a7516c7dfdda68272f629ce30d74c84694f
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
committed by
Isaac Manjarres
parent
603af016e4
commit
bd6df18cfd
@@ -294,19 +294,6 @@ impl UserSliceReader {
|
||||
unsafe { buf.inc_len(len) };
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Reads a nul-terminated string into the provided buffer and returns the length.
|
||||
pub fn strncpy_from_user(self, buf: &mut [u8]) -> Result<usize> {
|
||||
let max = usize::min(self.length, buf.len()) as isize;
|
||||
// SAFETY: `buf` is valid for writing `buf.len()` bytes.
|
||||
let res =
|
||||
unsafe { bindings::strncpy_from_user(buf.as_mut_ptr(), self.ptr as *const u8, max) };
|
||||
if res >= 0 {
|
||||
Ok(res as usize)
|
||||
} else {
|
||||
Err(Error::from_errno(res as i32))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A writer for [`UserSlice`].
|
||||
|
||||
Reference in New Issue
Block a user