mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
committed by
Andreas Kling
parent
88ca12f037
commit
c05c5a7ff4
@@ -456,10 +456,10 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port,
|
||||
return true;
|
||||
}
|
||||
|
||||
String IPv4Socket::absolute_path(const OpenFileDescription&) const
|
||||
KResultOr<NonnullOwnPtr<KString>> IPv4Socket::pseudo_path(const OpenFileDescription&) const
|
||||
{
|
||||
if (m_role == Role::None)
|
||||
return "socket";
|
||||
return KString::try_create("socket"sv);
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append("socket:");
|
||||
@@ -485,7 +485,7 @@ String IPv4Socket::absolute_path(const OpenFileDescription&) const
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return builder.to_string();
|
||||
return KString::try_create(builder.to_string());
|
||||
}
|
||||
|
||||
KResult IPv4Socket::setsockopt(int level, int option, Userspace<const void*> user_value, socklen_t user_value_size)
|
||||
|
||||
Reference in New Issue
Block a user