From: Ilia Alshanetsky Date: Tue, 16 Mar 2004 00:32:09 +0000 (+0000) Subject: MFH: Fixed bug #27559 (Corrected open_basedir resolving logic). X-Git-Tag: php-4.3.5RC4~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cf790dea18ac4eeb532054953f23782780c9883;p=php MFH: Fixed bug #27559 (Corrected open_basedir resolving logic). --- diff --git a/NEWS b/NEWS index 30ad7ae766..01c4223a66 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP 4 NEWS - Fixed bug #27590 (crash during shutdown when freeing persistent resources in ZTS mode). (Ilia) - Fixed bug #27582 (possible crashes in imagefilltoborder()). (Pierre) +- Fixed bug #27559 (Corrected open_basedir resolving logic). (Ilia) - Fixed bug #27530 (broken http auth when safe_mode is on and PCRE is disabled). (Ilia) - Fixed bug #27509 (broken getaddrinfo() causes fsockopen() error). (Sara) diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index ad3e4f9cc7..d75ae26e2e 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -132,11 +132,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) {