Skip to content

Commit 3d4f79d

Browse files
committed
Don't allow variables as attribute name
Attributes require a static class name... This fixes https://oss-fuzz.com/testcase-detail/6267052359942144.
1 parent b03cafd commit 3d4f79d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Attribute name cannot be a variable
3+
--FILE--
4+
<?php
5+
6+
<<$x>>
7+
class A {}
8+
9+
?>
10+
--EXPECTF--
11+
Parse error: syntax error, unexpected '$x' (T_VARIABLE), expecting identifier (T_STRING) or static (T_STATIC) or namespace (T_NAMESPACE) or \\ (T_NS_SEPARATOR) in %s on line %d

Zend/zend_language_parser.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ attribute_arguments:
325325
;
326326

327327
attribute_decl:
328-
class_name_reference
328+
class_name
329329
{ $$ = zend_ast_create(ZEND_AST_ATTRIBUTE, $1, NULL); }
330-
| class_name_reference '(' ')'
330+
| class_name '(' ')'
331331
{ $$ = zend_ast_create(ZEND_AST_ATTRIBUTE, $1, NULL); }
332-
| class_name_reference '(' attribute_arguments ')'
332+
| class_name '(' attribute_arguments ')'
333333
{ $$ = zend_ast_create(ZEND_AST_ATTRIBUTE, $1, $3); }
334334
;
335335

0 commit comments

Comments
 (0)