Update files.rs

This commit is contained in:
Bob Wen 2021-03-01 15:05:45 +08:00 committed by GitHub
parent 26ab54fe74
commit f4df2b9db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -499,7 +499,7 @@ pub fn from_getdents(fd: i32, path: &Path, nothidden: &AtomicUsize) -> Result<V
let name: &OsStr = {
// Safe as long as d_name is NULL terminated
let true_len = unsafe { libc::strlen(d.d_name.as_ptr() as *const i8) };
let true_len = unsafe { libc::strlen(d.d_name.as_ptr() as *const u8) };
// Safe if strlen returned without SEGFAULT on OOB (if d_name weren't NULL terminated)
let bytes: &[u8] = unsafe { std::slice::from_raw_parts(d.d_name.as_ptr() as *const u8,
true_len) };