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
Notes:
sideshowbarker
2024-07-17 21:07:44 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/f8ad3cc6a09 Pull-request: https://github.com/SerenityOS/serenity/pull/11785 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/creator1creeper1
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 }));
|
||||
|
||||
return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr<void> {
|
||||
StringBuilder builder;
|
||||
for (SlavePTY& slave_pty : list) {
|
||||
StringBuilder builder;
|
||||
builder.appendff("{}", slave_pty.index());
|
||||
builder.clear();
|
||||
TRY(builder.try_appendff("{}", slave_pty.index()));
|
||||
TRY(callback({ builder.string_view(), { fsid(), pty_index_to_inode_index(slave_pty.index()) }, 0 }));
|
||||
}
|
||||
return {};
|
||||
|
|
Loading…
Add table
Reference in a new issue