From 5b2c973cc33c22a00e7538ee087be08a3c89d92d Mon Sep 17 00:00:00 2001 From: Rummskartoffel Date: Thu, 20 Jan 2022 22:14:12 +0100 Subject: [PATCH] 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. --- Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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 argv; Vector envp;