iliaa           Thu Sep 29 12:31:49 2005 EDT

  Modified files:              (Branch: PHP_4_4)
    /php-src    NEWS 
    /php-src/ext/standard       basic_functions.c 
  Log:
  MFH:
  Fixed possible crash and/or memory corruption in import_request_variables()
  Fixed potential GLOBALS overwrite via import_request_variables().
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.920.2.43&r2=1.1247.2.920.2.44&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.920.2.43 php-src/NEWS:1.1247.2.920.2.44
--- php-src/NEWS:1.1247.2.920.2.43      Wed Sep 28 18:34:04 2005
+++ php-src/NEWS        Thu Sep 29 12:31:46 2005
@@ -1,6 +1,9 @@
 PHP 4                                                                      NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2005, Version 4.4.1
+- Fixed possible crash and/or memory corruption in import_request_variables().
+  (Ilia)
+- Fixed potential GLOBALS overwrite via import_request_variables(). (Ilia)
 - Fixed possible GLOBALS variable override when register_globals are ON.
   (Ilia, Stefan)
 - Fixed possible register_globals toggle via parse_str(). (Ilia, Stefan)
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.543.2.51.2.2&r2=1.543.2.51.2.3&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.543.2.51.2.2 
php-src/ext/standard/basic_functions.c:1.543.2.51.2.3
--- php-src/ext/standard/basic_functions.c:1.543.2.51.2.2       Tue Sep 13 
09:23:56 2005
+++ php-src/ext/standard/basic_functions.c      Thu Sep 29 12:31:48 2005
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.543.2.51.2.2 2005/09/13 13:23:56 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.543.2.51.2.3 2005/09/29 16:31:48 iliaa Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -3027,11 +3027,25 @@
        prefix = va_arg(args, char *);
        prefix_len = va_arg(args, uint);
 
-       new_key_len = prefix_len + hash_key->nKeyLength;
-       new_key = (char *) emalloc(new_key_len);
+       if (!prefix_len) {
+               if (!hash_key->nKeyLength) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric 
key detected - possible security hazard.");
+                       return 0;
+               } else if (!strcmp(hash_key->arKey, "GLOBALS")) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempted 
GLOBALS variable overwrite.");
+                       return 0; 
+               }
+       }
+
+       if (hash_key->nKeyLength) {
+               new_key_len = prefix_len + hash_key->nKeyLength;
+               new_key = (char *) emalloc(new_key_len);
 
-       memcpy(new_key, prefix, prefix_len);
-       memcpy(new_key+prefix_len, hash_key->arKey, hash_key->nKeyLength);
+               memcpy(new_key, prefix, prefix_len);
+               memcpy(new_key+prefix_len, hash_key->arKey, 
hash_key->nKeyLength);
+       } else {
+               new_key_len = spprintf(&new_key, 0, "%s%ld", prefix, 
hash_key->h);
+       }
 
        zend_hash_del(&EG(symbol_table), new_key, new_key_len);
        ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), new_key, new_key_len, 
*var, (*var)->refcount+1, 0);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to