Migrate away from unsafe set_len of Utf8CStr

This commit is contained in:
topjohnwu
2025-09-09 22:19:05 -07:00
parent c8caaa98f5
commit 111136733a
5 changed files with 108 additions and 64 deletions

View File

@@ -212,15 +212,15 @@ impl Directory {
) -> OsResult<'a, ()> {
buf.clear();
unsafe {
let r = readlinkat(
readlinkat(
self.as_raw_fd(),
name.as_ptr(),
buf.as_mut_ptr().cast(),
buf.capacity(),
)
.into_os_result("readlinkat", Some(name), None)? as usize;
buf.set_len(r);
.check_os_err("readlinkat", Some(name), None)?;
}
buf.rebuild().ok();
Ok(())
}