diff options
| author | Mike Dalessio <mike.dalessio@gmail.com> | 2023-08-29 17:01:09 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-08-30 18:27:49 +0000 |
| commit | bd0268372e09eb45d088c44a534a5302bdca9796 (patch) | |
| tree | 86256f1ea8dde4b63f62495691e4abfb7560e909 | |
| parent | 6f8126faebeddf8a93a7c0041c096bf584efcefb (diff) | |
[ruby/yarp] fix: trailing comment at end of file
Previously this resulted in invalid memory access.
Found by the fuzzer.
https://github.com/ruby/yarp/commit/a1c9404906
| -rw-r--r-- | test/yarp/fuzzer_test.rb | 1 | ||||
| -rw-r--r-- | yarp/yarp.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/test/yarp/fuzzer_test.rb b/test/yarp/fuzzer_test.rb index e2aa9dab61..8da1a2dc76 100644 --- a/test/yarp/fuzzer_test.rb +++ b/test/yarp/fuzzer_test.rb @@ -15,4 +15,5 @@ class FuzzerTest < Test::Unit::TestCase snippet "incomplete global variable", "$" snippet "incomplete symbol", ":" snippet "incomplete escaped string", '"\\' + snippet "trailing comment", "1\n#\n" end diff --git a/yarp/yarp.c b/yarp/yarp.c index 91c814af9a..ce991003f1 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -5908,7 +5908,7 @@ parser_lex(yp_parser_t *parser) { // Here we look for a "." or "&." following a "\n". const char *following = next_newline(next_content, parser->end - next_content); - while (following && (following < parser->end)) { + while (following && (following + 1 < parser->end)) { following++; following += yp_strspn_inline_whitespace(following, parser->end - following); |
