Fix #76813: Access_violation_near_NULL_on_source_operand#6464
Closed
cmb69 wants to merge 2 commits intophp:PHP-7.4from
Closed
Fix #76813: Access_violation_near_NULL_on_source_operand#6464cmb69 wants to merge 2 commits intophp:PHP-7.4from
cmb69 wants to merge 2 commits intophp:PHP-7.4from
Conversation
If no valid token has been recognized, we return `T_UNEXPECTED` instead of proceeding with an invalid scanner state. We also fix the only superficially related issue regarding empty input followed by `T_SEPARATOR` and command, which caused another segfault.
nikic
reviewed
Nov 27, 2020
sapi/phpdbg/phpdbg_lexer.l
Outdated
|
|
||
| <!*> := yyleng = (size_t) YYCURSOR - (size_t) yytext; | ||
| <!*> { | ||
| if (YYCURSOR == NULL) return T_UNEXPECTED; |
Member
Author
There was a problem hiding this comment.
Condider the following input: "a\b". When backtracking, re2c sets YYCURSOR to YYMARKER, which is NULL. The re2c documentation says it would not be necessary to initialize YYMARKER, but when I do it nonetheless, there is no NULL issue here anymore, but for some reason the lexer enters the <NORMAL>{GENERIC_ID} rule, albeit with an empty text (yyleng == 0) what causes issues in unescape_string(). I don't understand why that rule is executed, since GENERIC_ID is not supposed to be empty. Anyway, if I add a suitable default rule <NORMAL>* {return T_UNEXPECTED;}, I get the desired parse error.
We avoid `YYCURSOR` becoming `NULL` by initializing `YYMARKER`, and add a default rule for `<NORMAL>` where we catch unexpected input.
nikic
approved these changes
Nov 30, 2020
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If no valid token has been recognized, we return
T_UNEXPECTEDinsteadof proceeding with an invalid scanner state.
We also fix the only superficially related issue regarding empty input
followed by
T_SEPARATORand command, which caused another segfault.