mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
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.
This commit is contained in:
parent
fb3e46e930
commit
3e959618c3
8 changed files with 36 additions and 18 deletions
|
@ -166,11 +166,13 @@ bool Emulator::load_elf()
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String interpreter_path;
|
||||
if (!ELF::validate_program_headers(*(Elf32_Ehdr const*)elf_image_data.data(), elf_image_data.size(), (u8 const*)elf_image_data.data(), elf_image_data.size(), &interpreter_path)) {
|
||||
StringBuilder interpreter_path_builder;
|
||||
auto result_or_error = ELF::validate_program_headers(*(Elf32_Ehdr const*)elf_image_data.data(), elf_image_data.size(), (u8 const*)elf_image_data.data(), elf_image_data.size(), &interpreter_path_builder);
|
||||
if (result_or_error.is_error() || !result_or_error.value()) {
|
||||
reportln("failed to validate ELF file");
|
||||
return false;
|
||||
}
|
||||
auto interpreter_path = interpreter_path_builder.string_view();
|
||||
|
||||
VERIFY(!interpreter_path.is_null());
|
||||
dbgln("interpreter: {}", interpreter_path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue