Skip to content

Fix #79491: Search for .user.ini extends up to root dir #5417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sapi/cgi/cgi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ static void sapi_cgi_log_message(char *message, int syslog_type_int)

/* {{{ php_cgi_ini_activate_user_config
*/
static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const char *doc_root, size_t doc_root_len, int start)
static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const char *doc_root, size_t doc_root_len)
{
user_config_cache_entry *new_entry, *entry;
time_t request_time = (time_t)sapi_get_request_time();
Expand Down Expand Up @@ -842,7 +842,7 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const
#else
if (strncmp(s1, s2, s_len) == 0) {
#endif
char *ptr = s2 + start; /* start is the point where doc_root ends! */
char *ptr = s2 + doc_root_len;
while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) {
*ptr = 0;
php_parse_user_ini_file(path, PG(user_ini_filename), entry->user_config);
Expand Down Expand Up @@ -938,7 +938,7 @@ static int sapi_cgi_activate(void)
doc_root = estrndup(doc_root, doc_root_len);
zend_str_tolower(doc_root, doc_root_len);
#endif
php_cgi_ini_activate_user_config(path, path_len, doc_root, doc_root_len, (doc_root_len > 0 && (doc_root_len - 1)));
php_cgi_ini_activate_user_config(path, path_len, doc_root, doc_root_len);

#ifdef PHP_WIN32
efree(doc_root);
Expand Down