summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Allaert <pa@ez.no>2013-07-09 15:05:10 +0200
committerStanislav Malyshev <stas@php.net>2013-08-18 14:18:33 -0700
commit98d29d20a1e5d2d8bc1699fbc61efde95f5ce87f (patch)
treea0ce84e35786a28bd1cd6c9d21983b85e557307c
parenta3fa25e857ca5d714e72b25c7f6a2999d1df8a6b (diff)
downloadphp-git-98d29d20a1e5d2d8bc1699fbc61efde95f5ce87f.tar.gz
Fixed #65225: PHP_BINARY incorrectly set
-rw-r--r--main/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/main.c b/main/main.c
index b639ab1658..1fd82c8398 100644
--- a/main/main.c
+++ b/main/main.c
@@ -115,6 +115,10 @@
#endif
/* }}} */
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+
PHPAPI int (*php_register_internal_extensions_func)(TSRMLS_D) = php_register_internal_extensions;
#ifndef ZTS
@@ -276,13 +280,14 @@ static void php_binary_init(TSRMLS_D)
if ((envpath = getenv("PATH")) != NULL) {
char *search_dir, search_path[MAXPATHLEN];
char *last = NULL;
+ struct stat s;
path = estrdup(envpath);
search_dir = php_strtok_r(path, ":", &last);
while (search_dir) {
snprintf(search_path, MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
- if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
+ if (VCWD_REALPATH(search_path, binary_location) && !VCWD_ACCESS(binary_location, X_OK) && VCWD_STAT(binary_location, &s) == 0 && S_ISREG(s.st_mode)) {
found = 1;
break;
}