Merge
authorsherman
Fri, 24 Jul 2009 11:22:29 -0700
changeset 3417 171805bbec34
parent 3416 0dd4f82becda (current diff)
parent 3322 82096b9a8dd3 (diff)
child 3418 7502c0a41963
Merge
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_general.c	Fri Jul 24 11:06:57 2009 -0700
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_general.c	Fri Jul 24 11:22:29 2009 -0700
@@ -337,7 +337,7 @@
     CK_ULONG ckTokenNumber;
     CK_SLOT_ID_PTR ckpSlotList;
     CK_BBOOL ckTokenPresent;
-    jlongArray jSlotList;
+    jlongArray jSlotList = NULL;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -637,7 +637,7 @@
     CK_SLOT_ID ckSlotID;
     CK_ULONG ckMechanismNumber;
     CK_MECHANISM_TYPE_PTR ckpMechanismList;
-    jlongArray jMechanismList;
+    jlongArray jMechanismList = NULL;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c	Fri Jul 24 11:06:57 2009 -0700
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c	Fri Jul 24 11:22:29 2009 -0700
@@ -73,9 +73,8 @@
     CK_MECHANISM ckMechanism;
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
-    CK_OBJECT_HANDLE ckKeyHandle;
+    CK_OBJECT_HANDLE ckKeyHandle = 0;
     jlong jKeyHandle = 0L;
-    CK_ULONG i;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -151,8 +150,7 @@
     CK_OBJECT_HANDLE_PTR ckpPublicKeyHandle;  /* pointer to Public Key */
     CK_OBJECT_HANDLE_PTR ckpPrivateKeyHandle; /* pointer to Private Key */
     CK_OBJECT_HANDLE_PTR ckpKeyHandles;     /* pointer to array with Public and Private Key */
-    jlongArray jKeyHandles;
-    CK_ULONG i;
+    jlongArray jKeyHandles = NULL;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -299,9 +297,8 @@
     CK_ULONG ckWrappedKeyLength;
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
-    CK_OBJECT_HANDLE ckKeyHandle;
+    CK_OBJECT_HANDLE ckKeyHandle = 0;
     jlong jKeyHandle = 0L;
-    CK_ULONG i;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -478,8 +475,7 @@
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
     CK_OBJECT_HANDLE ckKeyHandle = 0;
-    jlong jKeyHandle;
-    CK_ULONG i;
+    jlong jKeyHandle = 0L;
     CK_RV rv;
     CK_OBJECT_HANDLE_PTR phKey = &ckKeyHandle;
 
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c	Fri Jul 24 11:06:57 2009 -0700
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c	Fri Jul 24 11:22:29 2009 -0700
@@ -72,8 +72,7 @@
     CK_OBJECT_HANDLE ckObjectHandle;
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
-    jlong jObjectHandle;
-    CK_ULONG i;
+    jlong jObjectHandle = 0L;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -114,8 +113,7 @@
     CK_OBJECT_HANDLE ckNewObjectHandle;
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
-    jlong jNewObjectHandle;
-    CK_ULONG i;
+    jlong jNewObjectHandle = 0L;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -180,7 +178,7 @@
     CK_SESSION_HANDLE ckSessionHandle;
     CK_OBJECT_HANDLE ckObjectHandle;
     CK_ULONG ckObjectSize;
-    jlong jObjectSize;
+    jlong jObjectSize = 0L;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -217,7 +215,7 @@
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
     CK_ULONG ckBufferLength;
-    CK_ULONG i, j;
+    CK_ULONG i;
     jobject jAttribute;
     CK_RV rv;
 
@@ -307,7 +305,6 @@
     CK_OBJECT_HANDLE ckObjectHandle;
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
-    CK_ULONG i;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -342,7 +339,6 @@
     CK_SESSION_HANDLE ckSessionHandle;
     CK_ATTRIBUTE_PTR ckpAttributes = NULL_PTR;
     CK_ULONG ckAttributesLength;
-    CK_ULONG i;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
@@ -385,7 +381,7 @@
     CK_ULONG ckMaxObjectLength;
     CK_OBJECT_HANDLE_PTR ckpObjectHandleArray;
     CK_ULONG ckActualObjectCount;
-    jlongArray jObjectHandleArray;
+    jlongArray jObjectHandleArray = NULL;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
     if (ckpFunctions == NULL) { return NULL; }
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sign.c	Fri Jul 24 11:06:57 2009 -0700
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_sign.c	Fri Jul 24 11:22:29 2009 -0700
@@ -110,7 +110,7 @@
     CK_BYTE_PTR ckpSignature;
     CK_ULONG ckDataLength;
     CK_ULONG ckSignatureLength = 0;
-    jbyteArray jSignature;
+    jbyteArray jSignature = NULL;
     CK_RV rv;
 
     CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_util.c	Fri Jul 24 11:06:57 2009 -0700
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_util.c	Fri Jul 24 11:22:29 2009 -0700
@@ -194,16 +194,14 @@
     jclass jPKCS11ExceptionClass;
     jmethodID jConstructor;
     jthrowable jPKCS11Exception;
-    jlong jErrorCode;
+    jlong jErrorCode = 0L;
 
-    if (returnValue == CKR_OK) {
-        return 0L ;
-    } else {
+    if (returnValue != CKR_OK) {
+        jErrorCode = ckULongToJLong(returnValue);
         jPKCS11ExceptionClass = (*env)->FindClass(env, CLASS_PKCS11EXCEPTION);
         if (jPKCS11ExceptionClass != NULL) {
             jConstructor = (*env)->GetMethodID(env, jPKCS11ExceptionClass, "<init>", "(J)V");
             if (jConstructor != NULL) {
-                jErrorCode = ckULongToJLong(returnValue);
                 jPKCS11Exception = (jthrowable) (*env)->NewObject(env, jPKCS11ExceptionClass, jConstructor, jErrorCode);
                 if (jPKCS11Exception != NULL) {
                     (*env)->Throw(env, jPKCS11Exception);
@@ -211,8 +209,8 @@
             }
         }
         (*env)->DeleteLocalRef(env, jPKCS11ExceptionClass);
-        return jErrorCode ;
     }
+    return jErrorCode ;
 }
 
 /*
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Fri Jul 24 11:06:57 2009 -0700
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Fri Jul 24 11:22:29 2009 -0700
@@ -300,7 +300,7 @@
 
 /* funktions to convert a CK-type array and the array length to a Java array */
 
-jcharArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength);
+jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength);
 jlongArray ckULongArrayToJLongArray(JNIEnv *env, const CK_ULONG_PTR ckpArray, CK_ULONG ckLength);
 jcharArray ckCharArrayToJCharArray(JNIEnv *env, const CK_CHAR_PTR ckpArray, CK_ULONG length);
 jcharArray ckUTF8CharArrayToJCharArray(JNIEnv *env, const CK_UTF8CHAR_PTR ckpArray, CK_ULONG ckLength);