src/java.base/share/classes/sun/security/provider/DigestBase.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/java.base/share/classes/sun/security/provider/DigestBase.java Thu Jun 25 12:09:49 2015
--- new/src/java.base/share/classes/sun/security/provider/DigestBase.java Thu Jun 25 12:09:48 2015
*** 26,35 ****
--- 26,38 ----
package sun.security.provider;
import java.security.MessageDigestSpi;
import java.security.DigestException;
import java.security.ProviderException;
+ import java.util.Objects;
+
+ import jdk.internal.HotSpotIntrinsicCandidate;
/**
* Common base message digest implementation for the Sun provider.
* It implements all the JCA methods as suitable for a Java message digest
* implementation of an algorithm based on a compression function (as all
*** 134,149 ****
--- 137,176 ----
}
}
// compress complete blocks
private int implCompressMultiBlock(byte[] b, int ofs, int limit) {
+ implCompressMultiBlockCheck(b, ofs, limit);
+ return implCompressMultiBlockImpl(b, ofs, limit);
+ }
+
+ @HotSpotIntrinsicCandidate
+ private int implCompressMultiBlockImpl(byte[] b, int ofs, int limit) {
for (; ofs <= limit; ofs += blockSize) {
implCompress(b, ofs);
}
return ofs;
}
+ private void implCompressMultiBlockCheck(byte[] b, int ofs, int limit) {
+ if (limit < 0) {
+ return; // not an error because implCompressMultiBlockImpl won't execute if limit < 0
+ // and an exception is thrown if ofs < 0.
+ }
+
+ Objects.requireNonNull(b);
+
+ if (ofs < 0 || ofs >= b.length) {
+ throw new ArrayIndexOutOfBoundsException(ofs);
+ }
+
+ int endIndex = (limit / blockSize) * blockSize + blockSize - 1;
+ if (endIndex >= b.length) {
+ throw new ArrayIndexOutOfBoundsException(endIndex);
+ }
+ }
+
// reset this object. See JCA doc.
protected final void engineReset() {
if (bytesProcessed == 0) {
// already reset, ignore
return;
src/java.base/share/classes/sun/security/provider/DigestBase.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File