Skip to content

Commit de7f3f0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #76813: Access violation near NULL on source operand
2 parents 034270d + 666833b commit de7f3f0

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

sapi/phpdbg/phpdbg_lexer.l

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void phpdbg_init_lexer (phpdbg_param_t *stack, char *input) {
3333

3434
YYSETCONDITION(INITIAL);
3535

36-
LEX(text) = YYCURSOR = (unsigned char *) input;
36+
LEX(text) = YYCURSOR = YYMARKER = (unsigned char *) input;
3737
LEX(len) = strlen(input);
3838
}
3939

@@ -165,6 +165,10 @@ INPUT ("\\"[#"']|["]("\\\\"|"\\"["]|[^\n\000"])+["]|[']("\\"[']|"\\\\"|[^\
165165
return T_ID;
166166
}
167167
168+
<NORMAL>* {
169+
return T_UNEXPECTED;
170+
}
171+
168172
<RAW>{INPUT} {
169173
phpdbg_init_param(yylval, STR_PARAM);
170174
yylval->str = estrdup(yytext);

sapi/phpdbg/phpdbg_parser.y

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg)
6363
%% /* Rules */
6464

6565
input
66-
: command { $$ = $1; }
67-
| input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; }
66+
: non_empty_input { $$ = $1; }
6867
| %empty
6968
;
7069

70+
non_empty_input
71+
: command { $$ = $1; }
72+
| non_empty_input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; }
73+
;
74+
7175
command
7276
: parameters { $$.top = PHPDBG_G(parser_stack)->top; }
7377
| full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); $$.top = PHPDBG_G(parser_stack)->top; }

sapi/phpdbg/tests/bug76813.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #76813 (Access_violation_near_NULL_on_source_operand)
3+
--PHPDBG--
4+
"#!==)===\377\377\276\242="
5+
#!==)===\377\377\276\242=
6+
--EXPECT--
7+
prompt> [Parse Error: syntax error, unexpected input, expecting $end]
8+
prompt> [Parse Error: syntax error, unexpected # (pound sign), expecting $end]
9+
prompt> [Parse Error: syntax error, unexpected # (pound sign), expecting $end]
10+
prompt>

0 commit comments

Comments
 (0)