From: Ilia Alshanetsky Date: Tue, 16 Mar 2004 00:31:22 +0000 (+0000) Subject: Fixed bug #27559 (Corrected open_basedir resolving logic). X-Git-Tag: php-5.0.0RC1RC2~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=542b034efafc4f88cc9162ef01448e792977bdea;p=php Fixed bug #27559 (Corrected open_basedir resolving logic). --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index efa2a6deda..d29a33b5b7 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -131,11 +131,13 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path 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 / */ resolved_basedir_len = strlen(resolved_basedir); - if (resolved_basedir[resolved_basedir_len -1] != PHP_DIR_SEPARATOR) { - resolved_basedir[resolved_basedir_len] = PHP_DIR_SEPARATOR; - resolved_basedir[++resolved_basedir_len] = '\0'; + if (basedir[strlen(basedir) - 1] == PHP_DIR_SEPARATOR) { + if (resolved_basedir[resolved_basedir_len - 1] == '/') { + resolved_basedir[resolved_basedir_len - 1] = PHP_DIR_SEPARATOR; + resolved_basedir[++resolved_basedir_len] = '\0'; + } } - + if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) { resolved_name_len = strlen(resolved_name); if (resolved_name[resolved_name_len - 1] != PHP_DIR_SEPARATOR) {