From: Ilia Alshanetsky Date: Wed, 30 Dec 2009 19:15:11 +0000 (+0000) Subject: Fixed bug #44827 (define() allows :: in constant names). X-Git-Tag: php-5.2.13RC1~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=667a7680b14c79d941a2a553481d4199a9c9d3e1;p=php Fixed bug #44827 (define() allows :: in constant names). --- diff --git a/NEWS b/NEWS index f542608fc3..64ceb696eb 100644 --- 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 diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 25cb220ea5..bc93056af4 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -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: