1 diff -up php-5.2.17/main/php_variables.c.bug-323016 php-5.2.17/main/php_variables.c
2 --- php-5.2.17/main/php_variables.c.bug-323016 2012-02-16 09:26:09.000000000 +0700
3 +++ php-5.2.17/main/php_variables.c 2012-02-16 09:29:47.000000000 +0700
7 #include "zend_globals.h"
10 /* for systems that need to override reading of environment variables */
11 void _php_import_environment_variables(zval *array_ptr TSRMLS_DC);
12 @@ -438,7 +439,10 @@ void _php_import_environment_variables(z
14 /* turn off magic_quotes while importing environment variables */
15 int magic_quotes_gpc = PG(magic_quotes_gpc);
16 - PG(magic_quotes_gpc) = 0;
18 + if (PG(magic_quotes_gpc)) {
19 + zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1);
22 for (env = environ; env != NULL && *env != NULL; env++) {
23 p = strchr(*env, '=');
24 @@ -581,7 +585,9 @@ static inline void php_register_server_v
25 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
27 PG(http_globals)[TRACK_VARS_SERVER] = array_ptr;
28 - PG(magic_quotes_gpc) = 0;
29 + if (PG(magic_quotes_gpc)) {
30 + zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1);
33 /* Server variables */
34 if (sapi_module.register_server_variables) {
35 diff -up php-5.2.17/sapi/cgi/cgi_main.c.bug-323016 php-5.2.17/sapi/cgi/cgi_main.c
36 --- php-5.2.17/sapi/cgi/cgi_main.c.bug-323016 2010-01-03 15:23:27.000000000 +0600
37 +++ php-5.2.17/sapi/cgi/cgi_main.c 2012-02-16 09:26:09.000000000 +0700
38 @@ -609,7 +609,9 @@ void cgi_php_import_environment_variable
39 int filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
41 /* turn off magic_quotes while importing environment variables */
42 - PG(magic_quotes_gpc) = 0;
43 + if (PG(magic_quotes_gpc)) {
44 + zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1);
46 for (zend_hash_internal_pointer_reset_ex(&request->env, &pos);
47 zend_hash_get_current_key_ex(&request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING &&
48 zend_hash_get_current_data_ex(&request->env, (void **) &val, &pos) == SUCCESS;