cvs: php-src(PHP_4_3) /main fopen_wrappers.c

From: Date: Tue, 22 Jul 2003 01:32:21 +0000
Subject: cvs: php-src(PHP_4_3) /main fopen_wrappers.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-22700@lists.php.net to get a copy of this message
iliaa Mon Jul 21 21:32:21 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/main fopen_wrappers.c Log: MFH: r1.165 safe_mode patch Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.153.2.5 php-src/main/fopen_wrappers.c:1.153.2.6 --- php-src/main/fopen_wrappers.c:1.153.2.5 Tue Jun 24 10:36:18 2003 +++ php-src/main/fopen_wrappers.c Mon Jul 21 21:32:21 2003 @@ -16,7 +16,7 @@ | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.153.2.5 2003/06/24 14:36:18 iliaa Exp $ */ +/* $Id: fopen_wrappers.c,v 1.153.2.6 2003/07/22 01:32:21 iliaa Exp $ */ /* {{{ includes */ @@ -214,45 +214,44 @@ */ 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)); + 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++; + } - 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; }

« previous php.cvs (#22700) next »