iliaa           Sun Sep 22 14:30:38 2002 EDT

  Modified files:              
    /php4/main  fopen_wrappers.c 
  Log:
  Fixed bug #19395
  
  
Index: php4/main/fopen_wrappers.c
diff -u php4/main/fopen_wrappers.c:1.147 php4/main/fopen_wrappers.c:1.148
--- php4/main/fopen_wrappers.c:1.147    Mon Sep  9 06:56:28 2002
+++ php4/main/fopen_wrappers.c  Sun Sep 22 14:30:38 2002
@@ -16,7 +16,7 @@
    |          Jim Winstead <[EMAIL PROTECTED]>                                 |
    +----------------------------------------------------------------------+
  */
-/* $Id: fopen_wrappers.c,v 1.147 2002/09/09 10:56:28 hyanantha Exp $ */
+/* $Id: fopen_wrappers.c,v 1.148 2002/09/22 18:30:38 iliaa Exp $ */
 
 /* {{{ includes
  */
@@ -107,6 +107,7 @@
        char resolved_basedir[MAXPATHLEN];
        char local_open_basedir[MAXPATHLEN];
        int local_open_basedir_pos;
+       int resolved_basedir_len;
        
        /* Special case basedir==".": Use script-directory */
        if ((strcmp(basedir, ".") == 0) && 
@@ -128,11 +129,20 @@
 
        /* Resolve the real path into resolved_name */
        if ((expand_filepath(path, resolved_name TSRMLS_CC) != NULL) && 
(expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) != NULL)) {
+               /* Handler for basedirs that end with a / */            
+               if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR) {
+                       resolved_basedir_len = strlen(resolved_basedir);
+                       resolved_basedir[resolved_basedir_len] = '/';
+                       resolved_basedir[++resolved_basedir_len] = '\0';
+               } else {
+                       resolved_basedir_len = strlen(resolved_basedir);        
+               }
+               
                /* Check the path */
 #ifdef PHP_WIN32
-               if (strncasecmp(resolved_basedir, resolved_name, 
strlen(resolved_basedir)) == 0) {
+               if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) 
+== 0) {
 #else
-               if (strncmp(resolved_basedir, resolved_name, strlen(resolved_basedir)) 
== 0) {
+               if (strncmp(resolved_basedir, resolved_name, resolved_basedir_len) == 
+0) {
 #endif
                        /* File is in the right directory */
                        return 0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to