summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2009-12-30 19:15:11 +0000
committerIlia Alshanetsky <iliaa@php.net>2009-12-30 19:15:11 +0000
commitb63f178e975c989279d381402b7ad0ab5ed842f3 (patch)
tree4b056b4f569a100dff9285bf01470d4215aeaaa0
parent72a9c6d37ab0424281b85233766e0dd5fc59f764 (diff)
downloadphp-git-b63f178e975c989279d381402b7ad0ab5ed842f3.tar.gz
Fixed bug #44827 (define() allows :: in constant names).
-rw-r--r--NEWS1
-rw-r--r--Zend/zend_builtin_functions.c29
2 files changed, 4 insertions, 26 deletions
diff --git a/NEWS b/NEWS
index 629ffb5553..cd166dca36 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PHP NEWS
in HTTP uploads). (Ilia)
- Fixed bug #47409 (extract() problem with array containing word "this").
(Ilia, chrisstocktonaz at gmail dot com)
+- Fixed bug #44827 (define() allows :: in constant names). (Ilia)
?? ??? 20??, PHP 5.3.2
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 72372180a8..b9c8b9e815 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -629,7 +629,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;
@@ -640,31 +639,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((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(class_name, use_heap);
- RETURN_FALSE;
- }
- free_alloca(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: