From ca0d683fbec2f0ea0b925039f1ddd0f777d8268a Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 28 Jul 2022 10:46:43 -0400 Subject: [PATCH] Fix the P11Cipher AES/ECB/PKCS5Padding array index out of range issue Signed-off-by: Tao Liu --- .../share/classes/sun/security/pkcs11/P11Cipher.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Cipher.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Cipher.java index 8b798a51be5..78a792b83a8 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Cipher.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Cipher.java @@ -22,6 +22,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + +/* + * =========================================================================== + * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved + * =========================================================================== + */ + package sun.security.pkcs11; import java.nio.ByteBuffer; @@ -604,7 +611,7 @@ private int implUpdate(byte[] in, int inOfs, int inLen, if (padBufferLen != 0) { if (padBufferLen != padBuffer.length) { int bufCapacity = padBuffer.length - padBufferLen; - if (inLen > bufCapacity) { + if (inLen >= bufCapacity) { bufferInputBytes(in, inOfs, bufCapacity); inOfs += bufCapacity; inLen -= bufCapacity;