-
Notifications
You must be signed in to change notification settings - Fork 687
Fix: avoid 1B OOB read at EOF after class static block (Fixes #5254) #5261
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
base: master
Are you sure you want to change the base?
Fix: avoid 1B OOB read at EOF after class static block (Fixes #5254) #5261
Conversation
…ript-project#5254) When a class static block ends at EOF (no trailing newline), the caller unconditionally consumed the next char after '}', causing a 1-byte OOB read in lexer_consume_next_character. Guard at the call site and raise the same parse error the next stage expects. JerryScript-DCO-1.0-Signed-off-by: Harriet Zhu [email protected]
fields_size += sizeof (scanner_location_t); | ||
|
||
lexer_consume_next_character (context_p); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else | ||
{ | ||
lexer_consume_next_character (context_p); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we don't need else
as parser_raise_error
will stop the execution.
else | |
{ | |
lexer_consume_next_character (context_p); | |
} | |
lexer_consume_next_character (context_p); |
|
|
||
lexer_consume_next_character (context_p); | ||
|
||
if (JERRY_UNLIKELY(context_p->source_p >= context_p->source_end_p)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (JERRY_UNLIKELY(context_p->source_p >= context_p->source_end_p)) | |
if (JERRY_UNLIKELY (context_p->source_p >= context_p->source_end_p)) |
When a class static block ends at EOF (no trailing newline), the caller unconditionally consumed the next char after '}', causing a 1-byte OOB read in lexer_consume_next_character. Guard at the call site and raise the same parse error the next stage expects.
JerryScript-DCO-1.0-Signed-off-by: Harriet Zhu [email protected]
PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING