mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
Kernel: Clarify ambiguous {File,Description}::absolute_path
Found due to smelly code in InodeFile::absolute_path. In particular, this replaces the following misleading methods: File::absolute_path This method *never* returns an actual path, and if called on an InodeFile (which is impossible), it would VERIFY_NOT_REACHED(). OpenFileDescription::try_serialize_absolute_path OpenFileDescription::absolute_path These methods do not guarantee to return an actual path (just like the other method), and just like Custody::absolute_path they do not guarantee accuracy. In particular, just renaming the method made a TOCTOU bug obvious. The new method signatures use KResultOr, just like try_serialize_absolute_path() already did.
This commit is contained in:
parent
88ca12f037
commit
c05c5a7ff4
28 changed files with 83 additions and 65 deletions
|
@ -365,15 +365,23 @@ private:
|
|||
fs_object.add("readonly", fs.is_readonly());
|
||||
fs_object.add("mount_flags", mount.flags());
|
||||
|
||||
if (fs.is_file_backed())
|
||||
fs_object.add("source", static_cast<const FileBackedFileSystem&>(fs).file_description().absolute_path());
|
||||
else
|
||||
if (fs.is_file_backed()) {
|
||||
auto pseudo_path_or_error = static_cast<const FileBackedFileSystem&>(fs).file_description().pseudo_path();
|
||||
if (pseudo_path_or_error.is_error()) {
|
||||
// We're probably out of memory and should not attempt to continue.
|
||||
result = pseudo_path_or_error.error();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
fs_object.add("source", pseudo_path_or_error.value()->characters());
|
||||
} else {
|
||||
fs_object.add("source", "none");
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
array.finish();
|
||||
return KSuccess;
|
||||
if (result == KSuccess)
|
||||
array.finish();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue