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.4.0alpha1~191^2~2144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ffd94cb723e775068350f57ad9b5b30f8e7eba6;p=php Fixed bug #44827 (define() allows :: in constant names). --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 00c235c8b6..322f186583 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -623,12 +623,25 @@ ZEND_FUNCTION(define) zend_bool non_cs = 0; int case_sensitive = CONST_CS; zend_constant c; + void *found = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tz|b", &name, &name_len, &name_type, &val, &non_cs) == FAILURE) { return; } - if(non_cs) { + if (name_type == IS_UNICODE) { + UChar *sep = USTR_MAKE("::"); + found = zend_u_memnstr(name.u, sep, sizeof("::") - 1, name.u + name_len); + efree(sep); + } else { + found = zend_memnstr(name.s, "::", sizeof("::") - 1, name.s + name_len); + } + if (found) { + zend_error(E_WARNING, "Class constants cannot be defined or redefined"); + RETURN_FALSE; + } + + if (non_cs) { case_sensitive = 0; }