CVS update: php3

From: Date: Sun, 13 Sep 1998 22:29:38 +0000
Subject: CVS update: php3
Groups: php.dev 
Request: Send a blank email to php-dev+get-1040@lists.php.net to get a copy of this message
Date: Sunday September 13, 1998 @ 18:29 Author: steffann Update of /repository/php3 In directory asf:/u2/tmp/cvs-serv24141 Modified Files: ChangeLog fopen-wrappers.c php3_realpath.c Log Message: Added special case for open_basedir and corrected some bugs in php3_realpath Index: php3/ChangeLog diff -c php3/ChangeLog:1.478 php3/ChangeLog:1.479 *** php3/ChangeLog:1.478 Sat Sep 12 10:44:05 1998 --- php3/ChangeLog Sun Sep 13 18:29:37 1998 *************** *** 1,6 **** --- 1,8 ---- PHP 3.0 CHANGE LOG ChangeLog ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Version 3.0.4 + - Added a special case for open_basedir. When open_basedir is set to "." + the directory in which the script is stored will be used as basedir. - Include alloca.c in the distribution for platforms without alloca(). - Improved stripping of URL passwords from error messages - the length of the username/password isn't obvious now, and all protocols are handled properly Index: php3/fopen-wrappers.c diff -c php3/fopen-wrappers.c:1.47 php3/fopen-wrappers.c:1.48 *** php3/fopen-wrappers.c:1.47 Sun Sep 13 14:35:08 1998 --- php3/fopen-wrappers.c Sun Sep 13 18:29:37 1998 *************** *** 27,33 **** | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ ! /* $Id: fopen-wrappers.c,v 1.47 1998/09/13 18:35:08 steffann Exp $ */ #ifdef THREAD_SAFE #include "tls.h" --- 27,33 ---- | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ ! /* $Id: fopen-wrappers.c,v 1.48 1998/09/13 22:29:37 steffann Exp $ */ #ifdef THREAD_SAFE #include "tls.h" *************** *** 107,122 **** PHPAPI int _php3_check_open_basedir(char *path) { char resolved_name[MAXPATHLEN]; /* Only check when open_basedir is available */ if (php3_ini.open_basedir && *php3_ini.open_basedir) { /* Resolve the real path into resolved_name */ if (_php3_realpath(path, resolved_name) != NULL) { /* Check the path */ #if WIN32|WINNT ! if (strncasecmp(php3_ini.open_basedir, resolved_name, strlen(php3_ini.open_basedir)) == 0) { #else ! if (strncmp(php3_ini.open_basedir, resolved_name, strlen(php3_ini.open_basedir)) == 0) { #endif /* File is in the right directory */ return 0; --- 107,164 ---- PHPAPI int _php3_check_open_basedir(char *path) { char resolved_name[MAXPATHLEN]; + char local_open_basedir[MAXPATHLEN]; + int local_open_basedir_pos; /* Only check when open_basedir is available */ if (php3_ini.open_basedir && *php3_ini.open_basedir) { + + /* Special case basedir==".": Use script-directory */ + if ((strcmp(php3_ini.open_basedir, ".") == 0) && + GLOBAL(request_info).filename && + *GLOBAL(request_info).filename + ) { + strcpy(local_open_basedir, GLOBAL(request_info).filename); + local_open_basedir_pos = strlen(local_open_basedir) - 1; + + /* Strip filename */ + while (( + #if WIN32|WINNT + (local_open_basedir[local_open_basedir_pos] != '\\') || + #endif + (local_open_basedir[local_open_basedir_pos] != '/') + ) && + (local_open_basedir_pos >= 0) + ) { + local_open_basedir[local_open_basedir_pos--] = 0; + } + + /* Strip double (back)slashes */ + if (local_open_basedir_pos > 0) { + while (( + #if WIN32|WINNT + (local_open_basedir[local_open_basedir_pos-1] == '\\') || + #endif + (local_open_basedir[local_open_basedir_pos-1] == '/') + ) && + (local_open_basedir_pos > 0) + ) { + local_open_basedir[local_open_basedir_pos--] = 0; + } + } + + } else { + /* Else use the unmodified path */ + strcpy(local_open_basedir, php3_ini.open_basedir); + } + /* Resolve the real path into resolved_name */ if (_php3_realpath(path, resolved_name) != NULL) { /* Check the path */ #if WIN32|WINNT ! if (strncasecmp(local_open_basedir, resolved_name, strlen(local_open_basedir)) == 0) { #else ! if (strncmp(local_open_basedir, resolved_name, strlen(local_open_basedir)) == 0) { #endif /* File is in the right directory */ return 0; Index: php3/php3_realpath.c diff -c php3/php3_realpath.c:1.7 php3/php3_realpath.c:1.8 *** php3/php3_realpath.c:1.7 Sun Sep 13 00:58:00 1998 --- php3/php3_realpath.c Sun Sep 13 18:29:38 1998 *************** *** 174,179 **** --- 174,182 ---- while((*workpos != '\\') && (*workpos != 0)) { *workpos++; } + + /* Avoid double \ in the result */ + writepos--; } /* If it was a directory, append a slash */ *************** *** 184,190 **** #else /* WIN32|WINNT */ /* Look for .. */ if ((workpos[0] == '.') && (workpos[1] != 0)) { ! if ((workpos[1] == '.') && (workpos[2] == '/')) { /* One directory back */ /* Set pointers to right position */ workpos++; /* move to second '.' */ --- 187,193 ---- #else /* WIN32|WINNT */ /* Look for .. */ if ((workpos[0] == '.') && (workpos[1] != 0)) { ! if ((workpos[1] == '.') && ((workpos[2] == '/') || (workpos[2] == 0))) { /* One directory back */ /* Set pointers to right position */ workpos++; /* move to second '.' */ *************** *** 196,205 **** while(*--writepos != '/') ; /* skip until previous '/' */ } } else { ! /* No special case, the name just started with a . */ ! /* Append */ ! while((*workpos != '/') && (*workpos != 0)) { ! *writepos++ = *workpos++; } } } else { --- 199,216 ---- while(*--writepos != '/') ; /* skip until previous '/' */ } } else { ! if (workpos[1] == '/') { ! /* Found a /./ skip it */ ! workpos++; /* move to '/' */ ! ! /* Avoid double / in the result */ ! writepos--; ! } else { ! /* No special case, the name just started with a . */ ! /* Append */ ! while((*workpos != '/') && (*workpos != 0)) { ! *writepos++ = *workpos++; ! } } } } else { -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1040) next »