]> granicus.if.org Git - php/commitdiff
Fix for bug 41899, safe mode and relative paths with Solaris's broken getcwd().
authorRobert Thompson <ab5602@php.net>
Wed, 10 Oct 2007 22:52:58 +0000 (22:52 +0000)
committerRobert Thompson <ab5602@php.net>
Wed, 10 Oct 2007 22:52:58 +0000 (22:52 +0000)
main/safe_mode.c

index 0c1523e57c8443ea0b84cab96c958a4d08186bf8..f5e7f9e7e8b59c974adce7bebec30674cf8eae43 100644 (file)
@@ -86,7 +86,15 @@ PHPAPI int php_checkuid_ex(const char *filename, const char *fopen_mode, int mod
         * If that fails, passthrough and check directory...
         */
        if (mode != CHECKUID_ALLOW_ONLY_DIR) {
-               expand_filepath(filename, path TSRMLS_CC);
+
+                char ftest[MAXPATHLEN];
+                strcpy(ftest,filename);
+                if (VCWD_GETCWD(ftest, sizeof(ftest)) == NULL) {
+                        strcpy(path,filename);
+                } else {
+                        expand_filepath(filename, path TSRMLS_CC);
+                        }
+
                ret = VCWD_STAT(path, &sb);
                if (ret < 0) {
                        if (mode == CHECKUID_DISALLOW_FILE_NOT_EXISTS) {