From 6638711aa9c4ca1edc391c11d9679fc5ab55191c Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 26 Mar 2008 23:43:35 +0000 Subject: [PATCH] execvp() also needs to verify that an entry it found in the path is a file. It would try to execute directories before (#1963). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24599 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/unistd/exec.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/system/libroot/posix/unistd/exec.cpp b/src/system/libroot/posix/unistd/exec.cpp index 77e98f771c..4cc631820b 100644 --- a/src/system/libroot/posix/unistd/exec.cpp +++ b/src/system/libroot/posix/unistd/exec.cpp @@ -164,6 +164,11 @@ execvp(const char *file, char* const* argv) strcat(path, "/"); strcat(path, file); + // check whether it is a file + struct stat st; + if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) + continue; + // if executable, execute it if (access(path, X_OK) == 0) return do_exec(path, argv, environ, true);