ext2: fix panic when encountering invalid UTF-8
This commit is contained in:
parent
baff0cd5bd
commit
7844116411
@ -118,7 +118,6 @@ impl<'a> Iterator for DirentIter<'a> {
|
|||||||
let dirent: &Dirent = bytemuck::from_bytes(&self.block[self.offset..entry_end]);
|
let dirent: &Dirent = bytemuck::from_bytes(&self.block[self.offset..entry_end]);
|
||||||
|
|
||||||
if dirent.ino == 0 {
|
if dirent.ino == 0 {
|
||||||
// TODO skip over empty/padding dirents
|
|
||||||
self.offset += dirent.ent_size as usize;
|
self.offset += dirent.ent_size as usize;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -329,7 +328,7 @@ impl DirectoryNode {
|
|||||||
|
|
||||||
pos += dirent.ent_size as u64;
|
pos += dirent.ent_size as u64;
|
||||||
|
|
||||||
let name = core::str::from_utf8(name).unwrap();
|
if let Ok(name) = core::str::from_utf8(name) {
|
||||||
entries[entry_count].write(DirectoryEntry {
|
entries[entry_count].write(DirectoryEntry {
|
||||||
ty: None,
|
ty: None,
|
||||||
name: FixedString::from_str(name)?,
|
name: FixedString::from_str(name)?,
|
||||||
@ -337,6 +336,7 @@ impl DirectoryNode {
|
|||||||
|
|
||||||
entry_count += 1;
|
entry_count += 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok((entry_count, pos))
|
Ok((entry_count, pos))
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user