]> granicus.if.org Git - php/commitdiff
Fixed bug#41361 (shell_exec() does not find binaries)
authorHannes Magnusson <bjori@php.net>
Sat, 12 May 2007 16:06:07 +0000 (16:06 +0000)
committerHannes Magnusson <bjori@php.net>
Sat, 12 May 2007 16:06:07 +0000 (16:06 +0000)
main/php_ini.c

index 8a7b5594aca3d9d5a9c718864fd5f52d7e3eee86..3b8e58d8c64f5081d3adbe674846bdf9fa9e3710 100644 (file)
@@ -352,12 +352,15 @@ int php_init_config(TSRMLS_D)
                if (sapi_module.executable_location) {
                        binary_location = (char *)emalloc(PATH_MAX);
                        if (!strchr(sapi_module.executable_location, '/')) {
-                               char *path;
+                               char *envpath, *path;
                                int found = 0;
 
-                               if ((path = getenv("PATH")) != NULL) {
+                               if ((envpath = getenv("PATH")) != NULL) {
                                        char *search_dir, search_path[MAXPATHLEN];
                                        char *last;
+                                       int pathlen = strlen(envpath) + 1;
+                                       path = malloc(pathlen);
+                                       memcpy(path, envpath, pathlen);
 
                                        search_dir = php_strtok_r(path, ":", &last);
                                        while (search_dir) {