cvs: php-src(PHP_5_0) / NEWS /main php_variables.c

From: Date: Thu, 17 Feb 2005 04:46:10 +0000
Subject: cvs: php-src(PHP_5_0) / NEWS /main php_variables.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-30450@lists.php.net to get a copy of this message
iliaa Wed Feb 16 23:46:10 2005 EDT Modified files: (Branch: PHP_5_0) /php-src NEWS /php-src/main php_variables.c Log: MFH: Fixed bug #31440 ($GLOBALS can be overwritten via GPC when register_globals is enabled). http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.246&r2=1.1760.2.247&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1760.2.246 php-src/NEWS:1.1760.2.247 --- php-src/NEWS:1.1760.2.246 Wed Feb 16 23:45:13 2005 +++ php-src/NEWS Wed Feb 16 23:46:09 2005 @@ -56,6 +56,8 @@ non-existent object ref). (Tony) - Fixed bug #31444 (Memory leak in zend_language_scanner.c). (hexer at studentcenter dot org) +- Fixed bug #31440 ($GLOBALS can be overwritten via GPC when register_globals + is enabled). (Ilia) - Fixed bug #31422 (No Error-Logging on SoapServer-Side). (Dmitry) - Fixed bug #31413 (curl POSTFIELDS crashes on 64-bit platforms). (Joe) - Fixed bug #31396 (compile fails with gd 2.0.33 without freetype). (Jani) http://cvs.php.net/diff.php/php-src/main/php_variables.c?r1=1.81.2.2&r2=1.81.2.3&ty=u Index: php-src/main/php_variables.c diff -u php-src/main/php_variables.c:1.81.2.2 php-src/main/php_variables.c:1.81.2.3 --- php-src/main/php_variables.c:1.81.2.2 Mon Oct 18 11:07:06 2004 +++ php-src/main/php_variables.c Wed Feb 16 23:46:10 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_variables.c,v 1.81.2.2 2004/10/18 15:07:06 tony2001 Exp $ */ +/* $Id: php_variables.c,v 1.81.2.3 2005/02/17 04:46:10 iliaa Exp $ */ #include <stdio.h> #include "php.h" @@ -531,6 +531,7 @@ ulong num_key; HashPosition pos; int key_type; + int globals_check = (PG(register_globals) && (dest == (&EG(symbol_table)))); zend_hash_internal_pointer_reset_ex(src, &pos); while (zend_hash_get_current_data_ex(src, (void **)&src_entry, &pos) == SUCCESS) { @@ -541,7 +542,12 @@ || Z_TYPE_PP(dest_entry) != IS_ARRAY) { (*src_entry)->refcount++; if (key_type == HASH_KEY_IS_STRING) { - zend_hash_update(dest, string_key, strlen(string_key)+1, src_entry, sizeof(zval *), NULL); + /* if register_globals is on and working with main symbol table, prevent overwriting of GLOBALS */ + if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) { + zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL); + } else { + (*src_entry)->refcount--; + } } else { zend_hash_index_update(dest, num_key, src_entry, sizeof(zval *), NULL); }

« previous php.cvs (#30450) next »