1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibELF: Ensure that DynamicLoader only receives absolute paths

While at it, start renaming variables where we know that they store a
path, so that we will get less confused in the future.
This commit is contained in:
Tim Schumacher 2022-10-28 16:30:27 +02:00 committed by Linus Groh
parent a1de15498d
commit 177a5baf60
5 changed files with 23 additions and 16 deletions

View file

@ -83,21 +83,21 @@ void _entry(int argc, char** argv, char** envp)
init_libc();
int main_program_fd = -1;
String main_program_name;
String main_program_path;
bool is_secure = false;
for (; auxvp->a_type != AT_NULL; ++auxvp) {
if (auxvp->a_type == ELF::AuxiliaryValue::ExecFileDescriptor) {
main_program_fd = auxvp->a_un.a_val;
}
if (auxvp->a_type == ELF::AuxiliaryValue::ExecFilename) {
main_program_name = (char const*)auxvp->a_un.a_ptr;
main_program_path = (char const*)auxvp->a_un.a_ptr;
}
if (auxvp->a_type == ELF::AuxiliaryValue::Secure) {
is_secure = auxvp->a_un.a_val == 1;
}
}
if (main_program_name == "/usr/lib/Loader.so"sv) {
if (main_program_path == "/usr/lib/Loader.so"sv) {
// We've been invoked directly as an executable rather than as the
// ELF interpreter for some other binary. In the future we may want
// to support launching a program directly from the dynamic loader
@ -107,9 +107,9 @@ void _entry(int argc, char** argv, char** envp)
}
VERIFY(main_program_fd >= 0);
VERIFY(!main_program_name.is_empty());
VERIFY(!main_program_path.is_empty());
ELF::DynamicLinker::linker_main(move(main_program_name), main_program_fd, is_secure, argc, argv, envp);
ELF::DynamicLinker::linker_main(move(main_program_path), main_program_fd, is_secure, argc, argv, envp);
VERIFY_NOT_REACHED();
}
}