mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:57:34 +00:00
Kernel: Harden DevPtsFSInode::traverse_as_directory against OOM
Use the try variants of AK::StringBuilder append APIs to harden this function against OOM.
This commit is contained in:
parent
787bfcc530
commit
f8ad3cc6a0
1 changed files with 3 additions and 2 deletions
|
@ -114,9 +114,10 @@ ErrorOr<void> DevPtsFSInode::traverse_as_directory(Function<ErrorOr<void>(FileSy
|
||||||
TRY(callback({ "..", identifier(), 0 }));
|
TRY(callback({ "..", identifier(), 0 }));
|
||||||
|
|
||||||
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<void> {
|
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<void> {
|
||||||
|
StringBuilder builder;
|
||||||
for (SlavePTY& slave_pty : list) {
|
for (SlavePTY& slave_pty : list) {
|
||||||
StringBuilder builder;
|
builder.clear();
|
||||||
builder.appendff("{}", slave_pty.index());
|
TRY(builder.try_appendff("{}", slave_pty.index()));
|
||||||
TRY(callback({ builder.string_view(), { fsid(), pty_index_to_inode_index(slave_pty.index()) }, 0 }));
|
TRY(callback({ builder.string_view(), { fsid(), pty_index_to_inode_index(slave_pty.index()) }, 0 }));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue