You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JRuby ext overflows slicing strings with non-zero begin #86
When the string provided to StringScanner.new is represented by a ByteList with a non-zero begin offset, the length for new strings is calculated incorrectly (length and begin get added together). No tests exist for this case, which typically happens when the source string has itself been sliced off the end of a larger string and still shares the same buffer.
$ jruby -rstrscan -e 'str = "hellohello"[5..-1]; StringScanner.new(str).scan(/hello/)'
Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 15 out of bounds for byte[10]
java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 15 out of bounds for byte[10]
arraycopy at java/lang/System.java:-2
<init> at org/jruby/util/ByteList.java:227
newString at org/jruby/ext/strscan/RubyStringScanner.java:877
extractBegLen at org/jruby/ext/strscan/RubyStringScanner.java:260
scan at org/jruby/ext/strscan/RubyStringScanner.java:342
scan at org/jruby/ext/strscan/RubyStringScanner.java:391
Activity
Don't add begin to length for new string slice
Don't add begin to length for new string slice (#87)
Update strscan to 3.1.0 for OOB fix
[ruby/strscan] Don't add begin to length for new string slice