8155608: String intrinsic range checks are not strict enough

Range checks in inflate, compress and getChars are not strict enough.

Reviewed-by: kvn, twisti, jrose
This commit is contained in:
Tobias Hartmann 2016-05-13 08:31:23 +02:00
parent bcec429910
commit dd051e31bb
2 changed files with 7 additions and 5 deletions

View file

@ -557,7 +557,7 @@ final class StringLatin1 {
// inflatedCopy byte[] -> char[]
@HotSpotIntrinsicCandidate
private static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
public static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
for (int i = 0; i < len; i++) {
dst[dstOff++] = (char)(src[srcOff++] & 0xff);
}
@ -567,7 +567,7 @@ final class StringLatin1 {
@HotSpotIntrinsicCandidate
public static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) {
// We need a range check here because 'putChar' has no checks
checkBoundsOffCount(dstOff, len, dst.length);
checkBoundsOffCount(dstOff << 1, len << 1, dst.length);
for (int i = 0; i < len; i++) {
StringUTF16.putChar(dst, dstOff++, src[srcOff++] & 0xff);
}