LibC: make execvp fail if no executable found

This commit is contained in:
Bananymous 2023-12-19 10:28:15 +02:00
parent f46240e879
commit 5edbb1d5c4
1 changed files with 11 additions and 1 deletions

View File

@ -183,7 +183,7 @@ int execve(const char* pathname, char* const argv[], char* const envp[])
int execvp(const char* file, char* const argv[])
{
char buffer[1024];
const char* pathname = file;
const char* pathname = NULL;
// do path resolution if file doesn't contain /
if (strchr(file, '/') == nullptr)
@ -218,6 +218,16 @@ int execvp(const char* file, char* const argv[])
cur++;
}
}
else
{
pathname = file;
}
if (!pathname)
{
errno = ENOENT;
return -1;
}
return execve(pathname, argv, environ);
}