From 8cf790dea18ac4eeb532054953f23782780c9883 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 16 Mar 2004 00:32:09 +0000 Subject: [PATCH] MFH: Fixed bug #27559 (Corrected open_basedir resolving logic). --- NEWS | 1 + main/fopen_wrappers.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) 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) { -- 2.40.0