mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:35:08 +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
|
@ -349,19 +349,18 @@ KResult OpenFileDescription::close()
|
|||
return m_file->close();
|
||||
}
|
||||
|
||||
KResultOr<NonnullOwnPtr<KString>> OpenFileDescription::try_serialize_absolute_path()
|
||||
KResultOr<NonnullOwnPtr<KString>> OpenFileDescription::original_absolute_path() const
|
||||
{
|
||||
if (!m_custody)
|
||||
return ENOENT;
|
||||
return m_custody->try_serialize_absolute_path();
|
||||
}
|
||||
|
||||
KResultOr<NonnullOwnPtr<KString>> OpenFileDescription::pseudo_path() const
|
||||
{
|
||||
if (m_custody)
|
||||
return m_custody->try_serialize_absolute_path();
|
||||
// FIXME: Don't go through a String here!
|
||||
return KString::try_create(m_file->absolute_path(*this));
|
||||
}
|
||||
|
||||
String OpenFileDescription::absolute_path() const
|
||||
{
|
||||
if (m_custody)
|
||||
return m_custody->absolute_path();
|
||||
return m_file->absolute_path(*this);
|
||||
return m_file->pseudo_path(*this);
|
||||
}
|
||||
|
||||
InodeMetadata OpenFileDescription::metadata() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue