]> granicus.if.org Git - php/commitdiff
MFH: r1.165 safe_mode patch
authorIlia Alshanetsky <iliaa@php.net>
Tue, 22 Jul 2003 01:32:21 +0000 (01:32 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 22 Jul 2003 01:32:21 +0000 (01:32 +0000)
main/fopen_wrappers.c

index 647fc18385a3e064543fc034ffe63558e0e44734..759d080bf2245280accb5c5b57239484cf1dedd1 100644 (file)
@@ -214,45 +214,44 @@ PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)
  */
 PHPAPI int php_check_safe_mode_include_dir(char *path TSRMLS_DC)
 {
-       /* Only check when safe_mode or open_basedir is on and safe_mode_include_dir is available */
-       if (((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) && 
-                       PG(safe_mode_include_dir) && *PG(safe_mode_include_dir))
-       {
-               char *pathbuf;
-               char *ptr;
-               char *end;
-               char resolved_name[MAXPATHLEN];
-
-               /* Resolve the real path into resolved_name */
-               if (expand_filepath(path, resolved_name TSRMLS_CC) == NULL)
-                       return -1;
-
-               pathbuf = estrdup(PG(safe_mode_include_dir));
-
-               ptr = pathbuf;
-
-               while (ptr && *ptr) {
-                       end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
-                       if (end != NULL) {
-                               *end = '\0';
-                               end++;
-                       }
+       if (PG(safe_mode)) {
+               if (PG(safe_mode_include_dir) && *PG(safe_mode_include_dir)) {
+                       char *pathbuf;
+                       char *ptr;
+                       char *end;
+                       char resolved_name[MAXPATHLEN];
+
+                       /* Resolve the real path into resolved_name */
+                       if (expand_filepath(path, resolved_name TSRMLS_CC) == NULL)
+                               return -1;
+
+                       pathbuf = estrdup(PG(safe_mode_include_dir));
+
+                       ptr = pathbuf;
+
+                       while (ptr && *ptr) {
+                               end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
+                               if (end != NULL) {
+                                       *end = '\0';
+                                       end++;
+                               }
 
-                       /* Check the path */
+                               /* Check the path */
 #ifdef PHP_WIN32
-                       if (strncasecmp(ptr, resolved_name, strlen(ptr)) == 0)
+                               if (strncasecmp(ptr, resolved_name, strlen(ptr)) == 0)
 #else
-                       if (strncmp(ptr, resolved_name, strlen(ptr)) == 0)
+                               if (strncmp(ptr, resolved_name, strlen(ptr)) == 0)
 #endif
-                       {
-                               /* File is in the right directory */
-                               efree(pathbuf);
-                               return 0;
-                       }
+                               {
+                                       /* File is in the right directory */
+                                       efree(pathbuf);
+                                       return 0;
+                               }
 
-                       ptr = end;
+                               ptr = end;
+                       }
+                       efree(pathbuf);
                }
-               efree(pathbuf);
                return -1;
        }