[ruby/yarp] fix: heredoc with incomplete escape at end of file
Previously this resulted in invalid memory access. Found by the fuzzer. https://github.com/ruby/yarp/commit/ec4abd87f4
This commit is contained in:
parent
341f47a6dd
commit
ae7f907559
@ -23,4 +23,5 @@ class FuzzerTest < Test::Unit::TestCase
|
||||
snippet "incomplete hex number", "0x"
|
||||
snippet "incomplete escaped list", "%w[\\"
|
||||
snippet "incomplete escaped regex", "/a\\"
|
||||
snippet "unterminated heredoc with unterminated escape at end of file", "<<A\n\\"
|
||||
end
|
||||
|
@ -7413,6 +7413,12 @@ parser_lex(yp_parser_t *parser) {
|
||||
break;
|
||||
}
|
||||
case '\\': {
|
||||
// Check that we're not at the end of the file.
|
||||
if (breakpoint + 1 >= parser->end) {
|
||||
breakpoint = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we hit an escape, then we need to skip past
|
||||
// however many characters the escape takes up. However
|
||||
// it's important that if \n or \r\n are escaped that we
|
||||
|
Loading…
x
Reference in New Issue
Block a user