Skip to content

Commit cd7e107

Browse files
committed
Add array bounds check to fnmatch impl
1 parent f86e439 commit cd7e107

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Bug fixes:
3737
* Fixed `#inspect` on broken UTF-8 sequences (#1842, @chrisseaton).
3838
* `Truffle::Interop.keys` should report methods of String and Symbol (#1817)
3939
* `Kernel#sprintf` encoding validity has been fixed (#1852, @XrXr).
40+
* Fixed File.fnmatch causes ArrayIndexOutOfBoundsException (#1845).
4041

4142
Compatibility:
4243

src/main/java/org/truffleruby/core/support/IONodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public static int fnmatch(
304304
}
305305
}
306306
/* failed : try next recursion */
307-
if (ptmp != -1 && stmp != -1 && !(period && string[stmp] == '.')) {
307+
if (ptmp != -1 && stmp != -1 && !(period && stmp < string.length && string[stmp] == '.')) {
308308
stmp = nextSlashIndex(string, stmp, send);
309309
if (stmp < send) {
310310
pat_pos = ptmp;

0 commit comments

Comments
 (0)