-
Notifications
You must be signed in to change notification settings - Fork 676
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
Out-of-bound read in main_print_unhandled_exception #4244
Comments
Thank you for analyzing the issue, few people are doing this. This is a great help for us! |
It is the same bug as #4212, but I leave this one open. affected test262-esnext tests: @dbatyai : This part of the source was refactored by edab196. |
https://nvd.nist.gov/vuln/detail/CVE-2020-29657 |
On line 180 of the main-utils.c,
do { ch = source_p[pos++]; jerry_port_log (JERRY_LOG_LEVEL_ERROR, "%c", ch); } while (ch != '\n' && char_count++ < SYNTAX_ERROR_MAX_LINE_LENGTH);
will out-of-bound read at most 0x100 characters when an syntax error happened at the end of the input file.
JerryScript revision
0ffe166
(latest master - 2020.09.28.)
Build platform
Ubuntu 16.04.1 (Linux 4.15.0-117-generic x86_64)
Build steps
Test case
Execution steps
Output
��'��x�^ �0��Catch or finally block expected.Y��^ �'��SyntaxE�($�^ xx ^ SyntaxError: Catch or finally block expected. [debugger.js:4:1]
Expected behavior
On line 166 of the main-utils.c
/* 2. seek and print */ while (pos < source_size && curr_line < err_line) { if (source_p[pos] == '\n') { curr_line++; } pos++; }
Please consider that the error line may be larger than the test case line number. The above "try" test case has just three lines, but the error happened on line 4 (a "catch" block is needed. ) The jerry_port_read_source (path_str_p, &source_size) called in the main_print_unhandled_exception need to malloc more memory to locate an error happened out of the source_size; meanwhile, the read operation on line 180 also need to be limited by the extended error location range instead of .
The text was updated successfully, but these errors were encountered: