-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #76813: Access violation near NULL on source operand
We avoid `YYCURSOR` becoming `NULL` by initializing `YYMARKER`, and add a default rule for `<NORMAL>` where we catch unexpected input. We also fix the only superficially related issue regarding empty input followed by `T_SEPARATOR` and command, which caused another segfault. Closes GH-6464.
- Loading branch information
Showing
4 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ void phpdbg_init_lexer (phpdbg_param_t *stack, char *input) { | |
|
||
YYSETCONDITION(INITIAL); | ||
|
||
LEX(text) = YYCURSOR = (unsigned char *) input; | ||
LEX(text) = YYCURSOR = YYMARKER = (unsigned char *) input; | ||
LEX(len) = strlen(input); | ||
} | ||
|
||
|
@@ -165,6 +165,10 @@ INPUT ("\\"[#"']|["]("\\\\"|"\\"["]|[^\n\000"])+["]|[']("\\"[']|"\\\\"|[^\ | |
return T_ID; | ||
} | ||
<NORMAL>* { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cmb69
Author
Contributor
|
||
return T_UNEXPECTED; | ||
} | ||
<RAW>{INPUT} { | ||
phpdbg_init_param(yylval, STR_PARAM); | ||
yylval->str = estrdup(yytext); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--TEST-- | ||
Bug #76813 (Access_violation_near_NULL_on_source_operand) | ||
--PHPDBG-- | ||
"#!==)===\377\377\276\242=" | ||
#!==)===\377\377\276\242= | ||
--EXPECT-- | ||
prompt> [Parse Error: syntax error, unexpected input, expecting $end] | ||
prompt> [Parse Error: syntax error, unexpected # (pound sign), expecting $end] | ||
prompt> [Parse Error: syntax error, unexpected # (pound sign), expecting $end] | ||
prompt> |
Note that this syntax requires re2c >= 0.13.7 and PHP 8 min version for re2c is set to 0.13.4. This will fail with a
re2c: error: line 168, column 9: syntax error
on re2c 0.13.4