Skip to content

Commit 3340e82

Browse files
author
Brian France
committed
Fixed a problem where opendir with <path>/ and having <path>/ 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.
1 parent 87c0577 commit 3340e82

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

main/fopen_wrappers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
108108
char local_open_basedir[MAXPATHLEN];
109109
int local_open_basedir_pos;
110110
int resolved_basedir_len;
111+
int resolved_name_len;
111112

112113
/* Special case basedir==".": Use script-directory */
113114
if ((strcmp(basedir, ".") == 0) &&
@@ -138,6 +139,12 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
138139
resolved_basedir_len = strlen(resolved_basedir);
139140
}
140141

142+
if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) {
143+
resolved_name_len = strlen(resolved_name);
144+
resolved_name[resolved_name_len] = '/';
145+
resolved_name[++resolved_name_len] = '\0';
146+
}
147+
141148
/* Check the path */
142149
#ifdef PHP_WIN32
143150
if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {

0 commit comments

Comments
 (0)