cvs: php4 /main php_virtual_cwd.c

From: Date: Sun, 20 Aug 2000 19:49:10 +0000
Subject: cvs: php4 /main php_virtual_cwd.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1272@lists.php.net to get a copy of this message
andi Sun Aug 20 12:49:10 2000 EDT Modified files: /php4/main php_virtual_cwd.c Log: - Checking for ".." isn't enough. include_once() could mess up even if both - names didn't include ".." but were referenced different directories which - were symlinked to each other. Index: php4/main/php_virtual_cwd.c diff -u php4/main/php_virtual_cwd.c:1.69 php4/main/php_virtual_cwd.c:1.70 --- php4/main/php_virtual_cwd.c:1.69 Sun Aug 20 11:12:16 2000 +++ php4/main/php_virtual_cwd.c Sun Aug 20 12:49:10 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_virtual_cwd.c,v 1.69 2000/08/20 18:12:16 andi Exp $ */ +/* $Id: php_virtual_cwd.c,v 1.70 2000/08/20 19:49:10 andi Exp $ */ #include <sys/types.h> #include <sys/stat.h> @@ -271,33 +271,30 @@ return (0); #ifndef ZEND_WIN32 - if (strstr(path, "..")) { - /* If .. is found then we need to resolve real path as the .. code doesn't work with symlinks */ - if (IS_ABSOLUTE_PATH(path, path_length)) { - if (realpath(path, resolved_path)) { - path = resolved_path; - path_length = strlen(path); - } - } else { /* Concat current directory with relative path and then run realpath() on it */ - char *tmp; - char *ptr; - - ptr = tmp = (char *) malloc(state->cwd_length+path_length+sizeof("/")); - if (!tmp) { - return 1; - } - memcpy(ptr, state->cwd, state->cwd_length); - ptr += state->cwd_length; - *ptr++ = DEFAULT_SLASH; - memcpy(ptr, path, path_length); - ptr += path_length; - *ptr = '\0'; - if (realpath(tmp, resolved_path)) { - path = resolved_path; - path_length = strlen(path); - } - free(tmp); + if (IS_ABSOLUTE_PATH(path, path_length)) { + if (realpath(path, resolved_path)) { + path = resolved_path; + path_length = strlen(path); } + } else { /* Concat current directory with relative path and then run realpath() on it */ + char *tmp; + char *ptr; + + ptr = tmp = (char *) malloc(state->cwd_length+path_length+sizeof("/")); + if (!tmp) { + return 1; + } + memcpy(ptr, state->cwd, state->cwd_length); + ptr += state->cwd_length; + *ptr++ = DEFAULT_SLASH; + memcpy(ptr, path, path_length); + ptr += path_length; + *ptr = '\0'; + if (realpath(tmp, resolved_path)) { + path = resolved_path; + path_length = strlen(path); + } + free(tmp); } #endif free_path = path_copy = estrndup(path, path_length);

« previous php.cvs (#1272) next »