summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibELF/DynamicLoader.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-01-13 18:50:17 +0200
committerAndreas Kling <kling@serenityos.org>2022-01-13 22:40:25 +0100
commit3e959618c3b3989228d6ba849f5c9e85a6b6a604 (patch)
treeed89c28a1837f3543f49c171696785b8cb2e7aaa /Userland/Libraries/LibELF/DynamicLoader.cpp
parentfb3e46e930aaf03fa1caec0cdf18ba48b12e1b0e (diff)
downloadserenity-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.cpp5
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;
}