iliaa Sat Jun 14 11:08:38 2003 EDT Modified files: (Branch: PHP_4_3) /php4/main main.c php_variables.c Log: MFH: Fixed bug #24007 (Problem with register_globals & arrays) Index: php4/main/main.c diff -u php4/main/main.c:1.512.2.39 php4/main/main.c:1.512.2.40 --- php4/main/main.c:1.512.2.39 Thu Jun 12 04:33:45 2003 +++ php4/main/main.c Sat Jun 14 11:08:37 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.512.2.39 2003/06/12 08:33:45 derick Exp $ */ +/* $Id: main.c,v 1.512.2.40 2003/06/14 15:08:37 iliaa Exp $ */ /* {{{ includes */ @@ -1495,6 +1495,20 @@ } } + 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: php4/main/php_variables.c diff -u php4/main/php_variables.c:1.45.2.3 php4/main/php_variables.c:1.45.2.4 --- php4/main/php_variables.c:1.45.2.3 Tue Dec 31 11:26:23 2002 +++ php4/main/php_variables.c Sat Jun 14 11:08:37 2003 @@ -16,7 +16,7 @@ | Zeev Suraski <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_variables.c,v 1.45.2.3 2002/12/31 16:26:23 sebastian Exp $ */ +/* $Id: php_variables.c,v 1.45.2.4 2003/06/14 15:08:37 iliaa Exp $ */ #include <stdio.h> #include "php.h" @@ -63,23 +63,15 @@ 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 @@ 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,18 +178,8 @@ } 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++; - } } }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php