summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2012-02-02 12:58:54 +0000
committerDmitry Stogov <dmitry@php.net>2012-02-02 12:58:54 +0000
commit87c038be06b8b0eb721270f98c858fd701f5d54b (patch)
tree682da688bcacfe588fc87f290b7eac18ba3ab1bf
parent89bc5ece51dde3edcb63fb8429d544cdcf8f1b60 (diff)
downloadphp-git-87c038be06b8b0eb721270f98c858fd701f5d54b.tar.gz
Always restore PG(magic_quote_gpc) on request shutdown
-rw-r--r--main/php_variables.c9
-rw-r--r--sapi/cgi/cgi_main.c4
-rw-r--r--sapi/fpm/fpm/fpm_main.c4
3 files changed, 13 insertions, 4 deletions
diff --git a/main/php_variables.c b/main/php_variables.c
index e50f5f7f7c..32588d5f8f 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -457,7 +457,10 @@ void _php_import_environment_variables(zval *array_ptr TSRMLS_DC)
/* turn off magic_quotes while importing environment variables */
int magic_quotes_gpc = PG(magic_quotes_gpc);
- PG(magic_quotes_gpc) = 0;
+
+ if (PG(magic_quotes_gpc)) {
+ zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
+ }
for (env = environ; env != NULL && *env != NULL; env++) {
p = strchr(*env, '=');
@@ -600,7 +603,9 @@ static inline void php_register_server_variables(TSRMLS_D)
zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
}
PG(http_globals)[TRACK_VARS_SERVER] = array_ptr;
- PG(magic_quotes_gpc) = 0;
+ if (PG(magic_quotes_gpc)) {
+ zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
+ }
/* Server variables */
if (sapi_module.register_server_variables) {
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 609ec8a9ac..6444781747 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -624,7 +624,9 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
int filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
/* turn off magic_quotes while importing environment variables */
- PG(magic_quotes_gpc) = 0;
+ if (PG(magic_quotes_gpc)) {
+ zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
+ }
for (zend_hash_internal_pointer_reset_ex(request->env, &pos);
zend_hash_get_current_key_ex(request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING &&
zend_hash_get_current_data_ex(request->env, (void **) &val, &pos) == SUCCESS;
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index ea0dd149f7..79ec9c37f1 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -595,7 +595,9 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
/* turn off magic_quotes while importing environment variables */
- PG(magic_quotes_gpc) = 0;
+ if (PG(magic_quotes_gpc)) {
+ zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
+ }
for (zend_hash_internal_pointer_reset_ex(request->env, &pos);
zend_hash_get_current_key_ex(request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING &&
zend_hash_get_current_data_ex(request->env, (void **) &val, &pos) == SUCCESS;