From: Ilia Alshanetsky Date: Wed, 30 Jul 2003 17:55:21 +0000 (+0000) Subject: MFH: Fixed bug #24873 (incorrect handling of / inside open_basedir) X-Git-Tag: php-4.3.3RC2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02a1624d2266d158e9c4276dc9792e4adcdc8f98;p=php MFH: Fixed bug #24873 (incorrect handling of / inside open_basedir) --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 759d080bf2..37f96c054d 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -130,19 +130,19 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path /* Resolve the real path into resolved_name */ 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 / */ - if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR) { - resolved_basedir_len = strlen(resolved_basedir); + /* Handler for basedirs that end with a / */ + resolved_basedir_len = strlen(resolved_basedir); + if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR && resolved_basedir[resolved_basedir_len -1] != PHP_DIR_SEPARATOR) { resolved_basedir[resolved_basedir_len] = '/'; resolved_basedir[++resolved_basedir_len] = '\0'; - } else { - resolved_basedir_len = strlen(resolved_basedir); } if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) { resolved_name_len = strlen(resolved_name); - resolved_name[resolved_name_len] = '/'; - resolved_name[++resolved_name_len] = '\0'; + if (resolved_name[resolved_name_len - 1] != PHP_DIR_SEPARATOR) { + resolved_name[resolved_name_len] = '/'; + resolved_name[++resolved_name_len] = '\0'; + } } /* Check the path */