1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

string.c: out-of-bounds access

* string.c (rb_str_enumerate_lines): fix out-of-bounds access when
  record separator is longer than the last element.  [Bug #14257]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-01-06 08:44:17 +00:00
parent 660740a75d
commit e043ae7348

View file

@ -8026,7 +8026,8 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary)
if (rsnewline) {
pend = chomp_newline(subptr, pend, enc);
}
else if (memcmp(pend - rslen, rsptr, rslen) == 0) {
else if (pend - subptr >= rslen &&
memcmp(pend - rslen, rsptr, rslen) == 0) {
pend -= rslen;
}
}