]> granicus.if.org Git - php/commitdiff
Fixed bug #24007 (Problem with register_globals & arrays)
authorIlia Alshanetsky <iliaa@php.net>
Sat, 14 Jun 2003 15:08:27 +0000 (15:08 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 14 Jun 2003 15:08:27 +0000 (15:08 +0000)
main/main.c
main/php_variables.c

index 68cbffa353c7b69c9f0a4706f2c29e0df83ea92b..1be845c08e57fac9282925579b62e9dd47c71a09 100644 (file)
@@ -1583,6 +1583,21 @@ static zend_bool php_auto_globals_create_request(TSRMLS_D)
                }
        }
 
+       if (PG(register_globals)) {
+               HashPosition pos;
+               zval **data;
+               char *string_key;
+               uint string_key_len;
+
+               zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(form_variables), &pos);
+               while (zend_hash_get_current_data_ex(Z_ARRVAL_P(form_variables), (void **)&data, &pos) == SUCCESS) {
+                       zend_hash_get_current_key_ex(Z_ARRVAL_P(form_variables), &string_key, &string_key_len, NULL, 0, &pos);
+
+                       ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), string_key, string_key_len, *data, (*data)->refcount+1, 0);
+                       zend_hash_move_forward_ex(Z_ARRVAL_P(form_variables), &pos);
+               }
+       }
+
        zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, sizeof(zval *), NULL);
 }
 #endif
index 0c3283fa797840347f18a4a39aebd137f842dab0..05516747d4e45e6de95709233f412e73121543ce 100644 (file)
@@ -67,23 +67,15 @@ PHPAPI void php_register_variable_ex(char *var, zval *val, pval *track_vars_arra
        char *ip;               /* index pointer */
        char *index;
        int var_len, index_len;
-       zval *gpc_element, **gpc_element_p, **top_gpc_p=NULL;
+       zval *gpc_element, **gpc_element_p;
        zend_bool is_array;
        HashTable *symtable1=NULL;
-       HashTable *symtable2=NULL;
 
        assert(var != NULL);
        
        if (track_vars_array) {
                symtable1 = Z_ARRVAL_P(track_vars_array);
        }
-       if (PG(register_globals)) {
-               if (symtable1) {
-                       symtable2 = EG(active_symbol_table);
-               } else {
-                       symtable1 = EG(active_symbol_table);
-               }       
-       }
        if (!symtable1) {
                /* Nothing to do */
                zval_dtor(val);
@@ -168,9 +160,6 @@ PHPAPI void php_register_variable_ex(char *var, zval *val, pval *track_vars_arra
                                        efree(escaped_index);
                                }
                        }
-                       if (!top_gpc_p) {
-                               top_gpc_p = gpc_element_p;
-                       }
                        symtable1 = Z_ARRVAL_PP(gpc_element_p);
                        /* ip pointed to the '[' character, now obtain the key */
                        index = index_s;
@@ -193,19 +182,9 @@ plain_var:
                        } else {
                                zend_hash_update(symtable1, index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
                        }
-                       if (!top_gpc_p) {
-                               top_gpc_p = gpc_element_p;
-                       }
                        break;
                }
        }
-
-       if (top_gpc_p) {
-               if (symtable2) {
-                       zend_hash_update(symtable2, var, var_len+1, top_gpc_p, sizeof(zval *), NULL);
-                       (*top_gpc_p)->refcount++;
-               }       
-       }
 }