]> granicus.if.org Git - php/commitdiff
php.ini search logic needs to use the absolute path of the running binary
authorHartmut Holzgraefe <hholzgra@php.net>
Wed, 27 Jul 2005 15:12:18 +0000 (15:12 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Wed, 27 Jul 2005 15:12:18 +0000 (15:12 +0000)
when looking for php.ini in the directory the php binary is installed in

main/php_ini.c

index e6dd1b8a347c40f3014089ed62ef1d08bb621a5a..452687f2d878cc9dd38852d2e5a8f8b1ca45faef 100644 (file)
@@ -350,7 +350,11 @@ int php_init_config()
                }
 #else
                if (sapi_module.executable_location) {
-                       binary_location = estrdup(sapi_module.executable_location);
+                       binary_location = (char *)emalloc(PATH_MAX);
+                       if (!realpath(sapi_module.executable_location, binary_location)) {
+                               efree(binary_location);
+                               binary_location = NULL;                  
+            }
                } else {
                        binary_location = NULL;
                }
@@ -359,7 +363,7 @@ int php_init_config()
                        char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
                        
                        if (separator_location) {
-                               *(separator_location+1) = 0;
+                               *(separator_location) = 0;
                        }
                        if (*php_ini_search_path) {
                                strcat(php_ini_search_path, paths_separator);