mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
uucore: fix potential use-after-free in utmpx iterator (#1737)
This commit is contained in:
parent
15eaaa9473
commit
c8977a78a4
1 changed files with 4 additions and 3 deletions
|
@ -242,9 +242,10 @@ impl UtmpxIter {
|
||||||
///
|
///
|
||||||
/// If not set, default record file will be used(file path depends on the target OS)
|
/// If not set, default record file will be used(file path depends on the target OS)
|
||||||
pub fn read_from(self, f: &str) -> Self {
|
pub fn read_from(self, f: &str) -> Self {
|
||||||
// FixME: discuss and revise a rewrite which is correct and satisfies clippy/rustc
|
let res = unsafe {
|
||||||
#[allow(clippy::temporary_cstring_as_ptr)]
|
let cstr = CString::new(f).unwrap();
|
||||||
let res = unsafe { utmpxname(CString::new(f).unwrap().as_ptr()) };
|
utmpxname(cstr.as_ptr())
|
||||||
|
};
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
println!("Warning: {}", IOError::last_os_error());
|
println!("Warning: {}", IOError::last_os_error());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue