changeset 7325:a982f3aa40ed

RH905128: [CRASH] OpenJDK-1.7.0 while using NSS security provider and kerberos
author andrew
date Wed, 21 May 2014 15:52:15 +0100
parents b4fc2a92ae21
children 521761df8dea
files src/share/classes/sun/security/pkcs11/P11Cipher.java
diffstat 1 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/pkcs11/P11Cipher.java	Wed May 21 15:25:53 2014 +0100
+++ b/src/share/classes/sun/security/pkcs11/P11Cipher.java	Wed May 21 15:52:15 2014 +0100
@@ -770,17 +770,19 @@
             ensureInitialized();
             int k = 0;
 	    if (encrypt) {
-		// Do we need to pad?
-		if (paddingObj != null) {
-		    int actualPadLen = paddingObj.setPaddingBytes(blockBuffer,
-			blockBufferLen, blockSize - blockBufferLen);
-		    blockBufferLen = blockSize;
+		if (blockBuffer != null) {
+		    // Do we need to pad?
+		    if (paddingObj != null) {
+			int actualPadLen = paddingObj.setPaddingBytes(blockBuffer,
+			    blockBufferLen, blockSize - blockBufferLen);
+			blockBufferLen = blockSize;
+		    }
+		    updating = true;
+		    k = token.p11.C_EncryptUpdate(session.id(),
+						  0, blockBuffer, 0, blockBufferLen,
+						  0, out, outOfs, outLen);
+		    updating = false;
 		}
-		updating = true;
-		k = token.p11.C_EncryptUpdate(session.id(),
-					      0, blockBuffer, 0, blockBufferLen,
-					      0, out, outOfs, outLen);
-		updating = false;
                 k += token.p11.C_EncryptFinal(session.id(),
                         0, out, (outOfs + k), (outLen - k));
             } else {
@@ -859,17 +861,19 @@
             int k = 0;
 
 	    if (encrypt) {
-		// Do we need to pad?
-		if (paddingObj != null) {
-		    int actualPadLen = paddingObj.setPaddingBytes(blockBuffer,
-			blockBufferLen, blockSize - blockBufferLen);
-		    blockBufferLen = blockSize;
-		}
-		updating = true;
-		k = token.p11.C_EncryptUpdate(session.id(),
+		if (blockBuffer != null) {
+		    // Do we need to pad?
+		    if (paddingObj != null) {
+			int actualPadLen = paddingObj.setPaddingBytes(blockBuffer,
+			    blockBufferLen, blockSize - blockBufferLen);
+			blockBufferLen = blockSize;
+		    }
+		    updating = true;
+		    k = token.p11.C_EncryptUpdate(session.id(),
 						  0, blockBuffer, 0, blockBufferLen,
 						  outAddr, outArray, outOfs, outLen);
-		updating = false;
+		    updating = false;
+		}
                 k += token.p11.C_EncryptFinal(session.id(),
                         outAddr, outArray, (outOfs + k), (outLen - k));
 	    } else {