Skip to content

Commit

Permalink
Fix user ini parsing under RC_DEBUG
Browse files Browse the repository at this point in the history
Suppress checking during the actual parsing, but make sure to
duplicate strings on activate. The parsing result may be shared
across requests, but activation should work on per-request strings.
  • Loading branch information
nikic committed Jul 21, 2021
1 parent 1da5df8 commit 21d9931
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main/php_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,17 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename
/* Reset active ini section */
RESET_ACTIVE_INI_HASH();

#if ZEND_RC_DEBUG
/* User inis are parsed during SAPI activate (part of the request),
* but persistently allocated to allow caching. This is fine as long as
* strings are duplicated in php_ini_activate_config(). */
bool orig_rc_debug = zend_rc_debug;
zend_rc_debug = false;
#endif
ret = zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, target_hash);
#if ZEND_RC_DEBUG
zend_rc_debug = orig_rc_debug;
#endif
if (ret == SUCCESS) {
/* FIXME: Add parsed file to the list of user files read? */
}
Expand All @@ -803,7 +813,9 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int

/* Walk through config hash and alter matching ini entries using the values found in the hash */
ZEND_HASH_FOREACH_STR_KEY_VAL(source_hash, str, data) {
zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0);
zend_string *data_str = zend_string_dup(Z_STR_P(data), 0);
zend_alter_ini_entry_ex(str, data_str, modify_type, stage, 0);
zend_string_release(data_str);
} ZEND_HASH_FOREACH_END();
}
/* }}} */
Expand Down

0 comments on commit 21d9931

Please sign in to comment.