]> granicus.if.org Git - php/commitdiff
Fixed a problem where opendir with <path>/ and having <path>/ in
authorBrian France <bfrance@php.net>
Fri, 4 Oct 2002 22:16:16 +0000 (22:16 +0000)
committerBrian France <bfrance@php.net>
Fri, 4 Oct 2002 22:16:16 +0000 (22:16 +0000)
        open_basedir ini option didn't work.  It was removing the trailing
        slashes and then addeding it back to only one of the string,
        now it adds it back to to both if needed.

main/fopen_wrappers.c

index 72b8e0a7bceedd82d4014f27f4eec3e23cb1af09..b5abebbca34820a45580cee2d7977613614b7f44 100644 (file)
@@ -108,6 +108,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
        char local_open_basedir[MAXPATHLEN];
        int local_open_basedir_pos;
        int resolved_basedir_len;
+       int resolved_name_len;
        
        /* Special case basedir==".": Use script-directory */
        if ((strcmp(basedir, ".") == 0) && 
@@ -138,6 +139,12 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
                        resolved_basedir_len = strlen(resolved_basedir);        
                }
                
+               if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) {
+                       resolved_name_len = strlen(resolved_name);
+                       resolved_name[resolved_name_len] = '/';
+                       resolved_name[++resolved_name_len] = '\0';
+               }
+
                /* Check the path */
 #ifdef PHP_WIN32
                if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {