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/Libraries/LibELF/DynamicLoader.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/Libraries/LibELF/DynamicLoader.cpp')
-rw-r--r-- | Userland/Libraries/LibELF/DynamicLoader.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index d0332c2f62..d2a986f483 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -122,8 +122,11 @@ bool DynamicLoader::validate() auto* elf_header = (ElfW(Ehdr)*)m_file_data; if (!validate_elf_header(*elf_header, m_file_size)) return false; - if (!validate_program_headers(*elf_header, m_file_size, (u8*)m_file_data, m_file_size, &m_program_interpreter)) + StringBuilder interpreter_path_builder; + auto result_or_error = validate_program_headers(*elf_header, m_file_size, (u8*)m_file_data, m_file_size, &interpreter_path_builder); + if (result_or_error.is_error() || !result_or_error.value()) return false; + m_program_interpreter = interpreter_path_builder.string_view(); return true; } |