mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
[ruby/yarp] fix: heredoc with incomplete escape at end of file
Previously this resulted in invalid memory access.
Found by the fuzzer.
ec4abd87f4
This commit is contained in:
parent
341f47a6dd
commit
ae7f907559
2 changed files with 7 additions and 0 deletions
|
@ -23,4 +23,5 @@ class FuzzerTest < Test::Unit::TestCase
|
||||||
snippet "incomplete hex number", "0x"
|
snippet "incomplete hex number", "0x"
|
||||||
snippet "incomplete escaped list", "%w[\\"
|
snippet "incomplete escaped list", "%w[\\"
|
||||||
snippet "incomplete escaped regex", "/a\\"
|
snippet "incomplete escaped regex", "/a\\"
|
||||||
|
snippet "unterminated heredoc with unterminated escape at end of file", "<<A\n\\"
|
||||||
end
|
end
|
||||||
|
|
|
@ -7413,6 +7413,12 @@ parser_lex(yp_parser_t *parser) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '\\': {
|
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
|
// If we hit an escape, then we need to skip past
|
||||||
// however many characters the escape takes up. However
|
// however many characters the escape takes up. However
|
||||||
// it's important that if \n or \r\n are escaped that we
|
// it's important that if \n or \r\n are escaped that we
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue