1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

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.
This commit is contained in:
Rummskartoffel 2022-01-20 22:14:12 +01:00 committed by Idan Horowitz
parent d2f99c200f
commit 5b2c973cc3

View file

@ -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;