From 3340e82508ee3cb7a3fabd4b2cd5eaeb5d75b8fe Mon Sep 17 00:00:00 2001 From: Brian France Date: Fri, 4 Oct 2002 22:16:16 +0000 Subject: [PATCH] Fixed a problem where opendir with / and having / in open_basedir ini option didn't work. It was removing the trailing slashes and then addeding it back to only one of the string, now it adds it back to to both if needed. --- main/fopen_wrappers.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 72b8e0a7bce..b5abebbca34 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -108,6 +108,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path char local_open_basedir[MAXPATHLEN]; int local_open_basedir_pos; int resolved_basedir_len; + int resolved_name_len; /* Special case basedir==".": Use script-directory */ if ((strcmp(basedir, ".") == 0) && @@ -138,6 +139,12 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path 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'; + } + /* Check the path */ #ifdef PHP_WIN32 if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {