From: Ilia Alshanetsky Date: Wed, 30 Jul 2003 17:55:06 +0000 (+0000) Subject: Fixed bug #24873 (incorrect handling of / inside open_basedir) X-Git-Tag: BEFORE_ARG_INFO~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ba651c692dd163204a0bdeb6db88cb826f93e12;p=php Fixed bug #24873 (incorrect handling of / inside open_basedir) --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index e12f0a992a..e709327672 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -129,19 +129,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 */