diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-13 18:50:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-13 22:40:25 +0100 |
commit | 3e959618c3b3989228d6ba849f5c9e85a6b6a604 (patch) | |
tree | ed89c28a1837f3543f49c171696785b8cb2e7aaa /Userland/Utilities/file.cpp | |
parent | fb3e46e930aaf03fa1caec0cdf18ba48b12e1b0e (diff) | |
download | serenity-3e959618c3b3989228d6ba849f5c9e85a6b6a604.zip |
LibELF: Use StringBuilders instead of Strings for the interpreter path
This is required for the Kernel's usage of LibELF, since Strings do not
expose allocation failure.
Diffstat (limited to 'Userland/Utilities/file.cpp')
-rw-r--r-- | Userland/Utilities/file.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp index 4728fed7b5..212dfc2a5e 100644 --- a/Userland/Utilities/file.cpp +++ b/Userland/Utilities/file.cpp @@ -67,9 +67,11 @@ static Optional<String> elf_details(String description, const String& path) if (!elf_image.is_valid()) return {}; - String interpreter_path; - if (!ELF::validate_program_headers(*(const ElfW(Ehdr)*)elf_data.data(), elf_data.size(), (const u8*)elf_data.data(), elf_data.size(), &interpreter_path)) + StringBuilder interpreter_path_builder; + auto result_or_error = ELF::validate_program_headers(*(const ElfW(Ehdr)*)elf_data.data(), elf_data.size(), (const u8*)elf_data.data(), elf_data.size(), &interpreter_path_builder); + if (result_or_error.is_error() || !result_or_error.value()) return {}; + auto interpreter_path = interpreter_path_builder.string_view(); auto& header = *reinterpret_cast<const ElfW(Ehdr)*>(elf_data.data()); |