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

index 6f9df74e8c89d28985de10b0c68f6f23c83cef6c..ac4e172ab0e9cd38e37b1b8139beaaa31285bcf2 100644 (file)
@@ -1495,6 +1495,20 @@ static int php_hash_environment(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);
        }
 
index f70f40c5e6b3190883754ccc9dcea98be91ffea7..067b21ea1762edb68319734818e38482099ea64b 100644 (file)
@@ -63,23 +63,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);
@@ -164,9 +156,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;
@@ -189,19 +178,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++;
-               }       
-       }
 }