mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
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:
parent
8adbc20c87
commit
b8dd2e555f
2 changed files with 156 additions and 4 deletions
|
@ -29,8 +29,48 @@ package java.lang;
|
|||
* A helper class to get access to package-private members
|
||||
*/
|
||||
public class Helper {
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static boolean StringCodingHasNegatives(byte[] ba, int off, int len) {
|
||||
return StringCoding.hasNegatives(ba, off, len);
|
||||
}
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static boolean StringCodingHasNegatives(byte[] ba, int off, int len) {
|
||||
return StringCoding.hasNegatives(ba, off, len);
|
||||
}
|
||||
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static byte[] compressByte(byte[] src, int srcOff, int dstSize, int dstOff, int len) {
|
||||
byte[] dst = new byte[dstSize];
|
||||
StringUTF16.compress(src, srcOff, dst, dstOff, len);
|
||||
return dst;
|
||||
}
|
||||
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static byte[] compressChar(char[] src, int srcOff, int dstSize, int dstOff, int len) {
|
||||
byte[] dst = new byte[dstSize];
|
||||
StringUTF16.compress(src, srcOff, dst, dstOff, len);
|
||||
return dst;
|
||||
}
|
||||
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static byte[] inflateByte(byte[] src, int srcOff, int dstSize, int dstOff, int len) {
|
||||
byte[] dst = new byte[dstSize];
|
||||
StringLatin1.inflate(src, srcOff, dst, dstOff, len);
|
||||
return dst;
|
||||
}
|
||||
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static char[] inflateChar(byte[] src, int srcOff, int dstSize, int dstOff, int len) {
|
||||
char[] dst = new char[dstSize];
|
||||
StringLatin1.inflate(src, srcOff, dst, dstOff, len);
|
||||
return dst;
|
||||
}
|
||||
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static byte[] toBytes(char[] value, int off, int len) {
|
||||
return StringUTF16.toBytes(value, off, len);
|
||||
}
|
||||
|
||||
@jdk.internal.vm.annotation.ForceInline
|
||||
public static char[] getChars(byte[] value, int srcBegin, int srcEnd, int dstSize, int dstBegin) {
|
||||
char[] dst = new char[dstSize];
|
||||
StringUTF16.getChars(value, srcBegin, srcEnd, dst, dstBegin);
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue