mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 17:58:06 +00:00
whoami: Restrict scope of unsafe
Co-authored-by: Jan Scheer <jhscheer@users.noreply.github.com>
This commit is contained in:
parent
0a3785bf84
commit
5bb56ec528
1 changed files with 2 additions and 4 deletions
|
@ -20,10 +20,8 @@ pub fn get_username() -> io::Result<OsString> {
|
|||
let mut buffer = [0_u16; BUF_LEN as usize];
|
||||
let mut len = BUF_LEN;
|
||||
// SAFETY: buffer.len() == len
|
||||
unsafe {
|
||||
if winbase::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
|
||||
if unsafe { winbase::GetUserNameW(buffer.as_mut_ptr(), &mut len) } == 0 {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
}
|
||||
Ok(OsString::from_wide(&buffer[..len as usize - 1]))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue