summaryrefslogtreecommitdiff
path: root/Userland/DevTools/UserspaceEmulator
diff options
context:
space:
mode:
authorRummskartoffel <Rummskartoffel@protonmail.com>2022-01-20 22:14:12 +0100
committerIdan Horowitz <idan.horowitz@gmail.com>2022-01-21 14:45:04 +0200
commit5b2c973cc33c22a00e7538ee087be08a3c89d92d (patch)
tree32e05e9c69f6908ee206f30ffceedf1c00913ec1 /Userland/DevTools/UserspaceEmulator
parentd2f99c200fbebe851d33fb1b990953d7587b1f5d (diff)
downloadserenity-5b2c973cc33c22a00e7538ee087be08a3c89d92d.zip
UserspaceEmulator: Correctly fail in execve when binary is inaccessible
Previously, Emulator::virt$execve would not report ENOENT and EACCES when the binary to be executed was nonexistent or not executable. This broke the execp family of functions, which rely on ENOENT being reported in order to know that they should continue searching $PATH.
Diffstat (limited to 'Userland/DevTools/UserspaceEmulator')
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
index 6b43e9ce45..2cc363927b 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
+++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
@@ -1225,6 +1225,11 @@ int Emulator::virt$execve(FlatPtr params_addr)
for (auto& argument : arguments)
reportln("=={}== - {}", getpid(), argument);
+ if (access(path.characters(), X_OK) < 0) {
+ if (errno == ENOENT || errno == EACCES)
+ return -errno;
+ }
+
Vector<char*> argv;
Vector<char*> envp;