From 4a4c840b9a02ea24414fc8682f87f583bbaee9cc Mon Sep 17 00:00:00 2001 From: bkurtz Date: Sun, 9 Oct 2022 05:02:17 -0700 Subject: fix path-searching for execvp --- libgcompat/unistd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libgcompat/unistd.c b/libgcompat/unistd.c index 7e9227d..011fba2 100644 --- a/libgcompat/unistd.c +++ b/libgcompat/unistd.c @@ -231,8 +231,19 @@ int execv(const char *pathname, char *const argv[]) { return execve(pathname, argv, environ); } +static int (*real_execvp)(const char *file, char *const argv[]); int execvp(const char *file, char *const argv[]) { - return execv(file, argv); + if(!strcmp(file, "/proc/self/exe")) { + return execv(file, argv); + } + if(real_execvp == NULL) { + real_execvp = dlsym(RTLD_NEXT, "execvp"); + if(real_execvp == NULL) { + errno = ENOSYS; + return -1; + } + } + return real_execvp(file, argv); } int __close(int fd) -- cgit v1.2.3-70-g09d2