From 3e959618c3b3989228d6ba849f5c9e85a6b6a604 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Thu, 13 Jan 2022 18:50:17 +0200 Subject: 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. --- Userland/Libraries/LibELF/DynamicLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibELF/DynamicLoader.cpp') 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; } -- cgit v1.2.3