]> granicus.if.org Git - php/commitdiff
Fixed bug #44827 (define() allows :: in constant names).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 30 Dec 2009 19:15:11 +0000 (19:15 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 30 Dec 2009 19:15:11 +0000 (19:15 +0000)
NEWS
Zend/zend_builtin_functions.c

diff --git a/NEWS b/NEWS
index f542608fc39a224c3ab6ca35251925f52ff9cd8c..64ceb696eb2bd0d47eab29dd42ead3590695fa3f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ PHP                                                                        NEWS
   then 1024 fields). (Ilia, sjoerd-php at linuxonly dot nl)
 - Fixed bug #45599 (strip_tags() truncates rest of string with invalid
   attribute). (Ilia, hradtke)  
+- Fixed bug #44827 (define() allows :: in constant names). (Ilia)
 
 
 17 Dec 2009, PHP 5.2.12
index 25cb220ea570a2ae31aa7ae3f0ea33527077339b..bc93056af43f751b09f860b234056bb0d4cf6e93 100644 (file)
@@ -461,7 +461,6 @@ ZEND_FUNCTION(define)
        zend_bool non_cs = 0;
        int case_sensitive = CONST_CS;
        zend_constant c;
-       char *p;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|b", &name, &name_len, &val, &non_cs) == FAILURE) {
                return;
@@ -472,31 +471,9 @@ ZEND_FUNCTION(define)
        }
 
        /* class constant, check if there is name and make sure class is valid & exists */
-       if ((p = zend_memnstr(name, "::", sizeof("::") - 1, name + name_len))) {
-               char *class_name;
-               int found;
-               zend_class_entry **ce;
-               ALLOCA_FLAG(use_heap)
-
-               if (p == (name + name_len - sizeof("::") + 1)) {
-                       zend_error(E_WARNING, "Class constant must have a name");
-                       RETURN_FALSE;
-               } else if (p == name) {
-                       zend_error(E_WARNING, "Missing class name");
-                       RETURN_FALSE;
-               }
-
-               class_name = do_alloca_with_limit((p - name + 1), use_heap);
-               zend_str_tolower_copy(class_name, name, (p - name));
-
-               found = zend_hash_find(EG(class_table), class_name, p - name + 1, (void **) &ce);
-
-               if (found != SUCCESS) {
-                       zend_error(E_WARNING, "Class '%s' does not exist", class_name);
-                       free_alloca_with_limit(class_name, use_heap);
-                       RETURN_FALSE;
-               }
-               free_alloca_with_limit(class_name, use_heap);
+       if (zend_memnstr(name, "::", sizeof("::") - 1, name + name_len)) {
+               zend_error(E_WARNING, "Class constants cannot be defined or redefined");
+               RETURN_FALSE;
        }
 
 repeat: