-
Notifications
You must be signed in to change notification settings - Fork 684
Fix heap buffer overflow in re_parse_char_class #2352
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
Fix heap buffer overflow in re_parse_char_class #2352
Conversation
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.
Other than the style issues, the patch looks good.
One comment to the commit message: to get the fixed issues automatically closed when the PR gets merged, all referenced issue numbers must be preceded by a closing keyword as described here: https://help.github.com/articles/closing-issues-using-keywords/#closing-multiple-issues . So, it should read "This patch fixes NNN and fixes MMM."
jerry-core/parser/regexp/re-parser.c
Outdated
if (is_range == false && lit_utf8_peek_next (parser_ctx_p->input_curr_p) == LIT_CHAR_MINUS) | ||
if (parser_ctx_p->input_curr_p < parser_ctx_p->input_end_p && | ||
is_range == false && | ||
lit_utf8_peek_next (parser_ctx_p->input_curr_p) == LIT_CHAR_MINUS) |
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.
The formatting of this condition is out of style. It should be
if (cond1
&& cond2
&& cond3)
{
}
jerry-core/parser/regexp/re-parser.c
Outdated
if (is_range == false && lit_utf8_peek_next (parser_ctx_p->input_curr_p) == LIT_CHAR_MINUS) | ||
if (parser_ctx_p->input_curr_p < parser_ctx_p->input_end_p && | ||
is_range == false && | ||
lit_utf8_peek_next (parser_ctx_p->input_curr_p) == LIT_CHAR_MINUS) |
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.
same style issue
219bed1
to
fcf074b
Compare
@akosthekiss Thanks for the review, I've applied your suggestions. |
|
||
try { | ||
((new RegExp("[\\u0")).exec("u")); | ||
} catch (e) { |
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.
One more note: is it expected that the regex exec throws an exception? In that case we should add an assert (false)
after the regex and before the catch IMO. Otherwise the test could pass without checking any assertions.
(same note to all try-catches in both tests)
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.
Good catch! Also the PR is rebased to the latest master.
fcf074b
to
8087edd
Compare
This patch fixes jerryscript-project#2230 and fixes jerryscript-project#2237. Test cases are added for both issues and also adds new cases which caused the same error. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
8087edd
to
7c3f2bc
Compare
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.
LGTM
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.
LGTM
This patch fixes #2230 and fixes #2237.
Test cases are added for both issues and also adds new cases which caused the same error.
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]