Skip to content

Fix #76813: Access_violation_near_NULL_on_source_operand #6464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Nov 27, 2020

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.

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.
@cmb69 cmb69 added the Bug label Nov 27, 2020
@@ -84,7 +84,10 @@ ADDR [0][x][a-fA-F0-9]+
OPCODE (ZEND_|zend_)([A-Za-z])+
INPUT ("\\"[#"']|["]("\\\\"|"\\"["]|[^\n\000"])+["]|[']("\\"[']|"\\\\"|[^\n\000'])+[']|[^\n\000#"'])+

<!*> := yyleng = (size_t) YYCURSOR - (size_t) yytext;
<!*> {
if (YYCURSOR == NULL) return T_UNEXPECTED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does YYCURSOR become null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@php-pulls php-pulls closed this in 5e15c9c Nov 30, 2020
@cmb69 cmb69 deleted the cmb/76813 branch November 30, 2020 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants