summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-07 17:27:38 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-07 17:28:00 +0200
commitee5e8081da08ae73abc5c7fc1a199c6ad57da253 (patch)
tree8602ab021e6fe8c55e46483efecf7dff091af84a
parent91d259ef1c43730b213788ac431e2692b3c3fdd7 (diff)
downloadserenity-ee5e8081da08ae73abc5c7fc1a199c6ad57da253.zip
UserspaceEmulator: Pass full path to new UE instance in virt$execve()
Don't just pass argv[0] to the new UE, pass the full program path.
-rw-r--r--DevTools/UserspaceEmulator/Emulator.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp
index 03331a6b07..91e2c1420a 100644
--- a/DevTools/UserspaceEmulator/Emulator.cpp
+++ b/DevTools/UserspaceEmulator/Emulator.cpp
@@ -963,6 +963,7 @@ int Emulator::virt$execve(FlatPtr params_addr)
report("\n");
report("==%d== \033[33;1mSyscall:\033[0m execve\n", getpid());
+ report("==%d== @ %s\n", getpid(), path.characters());
for (auto& argument : arguments)
report("==%d== - %s\n", getpid(), argument.characters());
@@ -970,6 +971,7 @@ int Emulator::virt$execve(FlatPtr params_addr)
Vector<char*> envp;
argv.append(const_cast<char*>("/bin/UserspaceEmulator"));
+ argv.append(const_cast<char*>(path.characters()));
auto create_string_vector = [](auto& output_vector, auto& input_vector) {
for (auto& string : input_vector)
@@ -980,6 +982,9 @@ int Emulator::virt$execve(FlatPtr params_addr)
create_string_vector(argv, arguments);
create_string_vector(envp, environment);
+ // Yoink duplicated program name.
+ argv.remove(2);
+
return execve(argv[0], (char* const*)argv.data(), (char* const*)envp.data());
}