8231222: fix pkcs11 P11_DEBUG guarded native traces

Reviewed-by: clanger
This commit is contained in:
Matthias Baesken 2019-09-23 17:02:08 +02:00
parent e2ebf7b822
commit 0e264cfe36
5 changed files with 23 additions and 21 deletions

View File

@ -1179,7 +1179,7 @@ CK_MECHANISM_PTR jMechanismToCKMechanismPtr(JNIEnv *env, jobject jMech)
throwOutOfMemoryError(env, 0); throwOutOfMemoryError(env, 0);
return NULL; return NULL;
} }
TRACE1("DEBUG jMechanismToCKMechanismPtr: allocated mech 0x%lX\n", ckpMech); TRACE1("DEBUG jMechanismToCKMechanismPtr: allocated mech %p \n", ckpMech);
ckpMech->mechanism = jLongToCKULong(jMechType); ckpMech->mechanism = jLongToCKULong(jMechType);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -98,7 +98,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_freeMechanism
(JNIEnv *env, jclass thisClass, jlong ckpMechanism) { (JNIEnv *env, jclass thisClass, jlong ckpMechanism) {
if (ckpMechanism != 0L) { if (ckpMechanism != 0L) {
freeCKMechanismPtr(jlong_to_ptr(ckpMechanism)); freeCKMechanismPtr(jlong_to_ptr(ckpMechanism));
TRACE1("DEBUG PKCS11_freeMechanism: free pMech = %x\n", ckpMechanism); TRACE1("DEBUG PKCS11_freeMechanism: free pMech = %lld\n", (long long int) ckpMechanism);
} }
return 0L; return 0L;
} }
@ -232,7 +232,10 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Initialize
free(ckpInitArgs); free(ckpInitArgs);
if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
TRACE1("DEBUG: C_Initialize had a bad return value %lu \n", (unsigned long) rv);
return;
}
TRACE0("FINISHED\n"); TRACE0("FINISHED\n");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -223,18 +223,18 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetAttributeVa
if (ckpFunctions == NULL) { return; } if (ckpFunctions == NULL) { return; }
TRACE0("DEBUG: C_GetAttributeValue"); TRACE0("DEBUG: C_GetAttributeValue");
TRACE1(", hSession=%u", jSessionHandle); TRACE1(", hSession=%lld", (long long) jSessionHandle);
TRACE1(", hObject=%u", jObjectHandle); TRACE1(", hObject=%lld", (long long) jObjectHandle);
TRACE1(", pTemplate=%p", jTemplate); TRACE1(", pTemplate=%p", jTemplate);
TRACE0(" ... "); TRACE0(" ... ");
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
ckObjectHandle = jLongToCKULong(jObjectHandle); ckObjectHandle = jLongToCKULong(jObjectHandle);
TRACE1("jAttributeArrayToCKAttributeArray now with jTemplate = %d", jTemplate); TRACE1("jAttributeArrayToCKAttributeArray now with jTemplate = %p", jTemplate);
jAttributeArrayToCKAttributeArray(env, jTemplate, &ckpAttributes, &ckAttributesLength); jAttributeArrayToCKAttributeArray(env, jTemplate, &ckpAttributes, &ckAttributesLength);
if ((*env)->ExceptionCheck(env)) { return; } if ((*env)->ExceptionCheck(env)) { return; }
TRACE2("DEBUG: jAttributeArrayToCKAttributeArray finished with ckpAttribute = %d, Length = %d\n", ckpAttributes, ckAttributesLength); TRACE2("DEBUG: jAttributeArrayToCKAttributeArray finished with ckpAttribute = %p, Length = %lu\n", ckpAttributes, (unsigned long) ckAttributesLength);
/* first set all pValue to NULL, to get the needed buffer length */ /* first set all pValue to NULL, to get the needed buffer length */
for(i = 0; i < ckAttributesLength; i++) { for(i = 0; i < ckAttributesLength; i++) {
@ -345,7 +345,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObjectsIni
if (ckpFunctions == NULL) { return; } if (ckpFunctions == NULL) { return; }
TRACE0("DEBUG: C_FindObjectsInit"); TRACE0("DEBUG: C_FindObjectsInit");
TRACE1(", hSession=%u", jSessionHandle); TRACE1(", hSession=%lld", (long long int) jSessionHandle);
TRACE1(", pTemplate=%p", jTemplate); TRACE1(", pTemplate=%p", jTemplate);
TRACE0(" ... "); TRACE0(" ... ");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -117,8 +117,8 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession
#endif /* NO_CALLBACKS */ #endif /* NO_CALLBACKS */
TRACE0("DEBUG: C_OpenSession"); TRACE0("DEBUG: C_OpenSession");
TRACE1(", slotID=%u", ckSlotID); TRACE1(", slotID=%lu", ckSlotID);
TRACE1(", flags=%x", ckFlags); TRACE1(", flags=%lu", (unsigned long) ckFlags);
TRACE0(" ... "); TRACE0(" ... ");
rv = (*ckpFunctions->C_OpenSession)(ckSlotID, ckFlags, ckpApplication, ckNotify, &ckSessionHandle); rv = (*ckpFunctions->C_OpenSession)(ckSlotID, ckFlags, ckpApplication, ckNotify, &ckSessionHandle);
@ -136,7 +136,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession
} }
TRACE0("got session"); TRACE0("got session");
TRACE1(", SessionHandle=%u", ckSessionHandle); TRACE1(", SessionHandle=%lu", (unsigned long) ckSessionHandle);
TRACE0(" ... "); TRACE0(" ... ");
jSessionHandle = ckULongToJLong(ckSessionHandle); jSessionHandle = ckULongToJLong(ckSessionHandle);

View File

@ -719,16 +719,15 @@ void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jArray, CK_ATTR
throwOutOfMemoryError(env, 0); throwOutOfMemoryError(env, 0);
return; return;
} }
TRACE1(", converting %d attributes", jLength); TRACE1(", converting %lld attributes", (long long int) jLength);
for (i=0; i<(*ckpLength); i++) { for (i=0; i<(*ckpLength); i++) {
TRACE1(", getting %d. attribute", i); TRACE1(", getting %lu. attribute", i);
jAttribute = (*env)->GetObjectArrayElement(env, jArray, i); jAttribute = (*env)->GetObjectArrayElement(env, jArray, i);
if ((*env)->ExceptionCheck(env)) { if ((*env)->ExceptionCheck(env)) {
freeCKAttributeArray(*ckpArray, i); freeCKAttributeArray(*ckpArray, i);
return; return;
} }
TRACE1(", jAttribute = %d", jAttribute); TRACE1(", jAttribute , converting %lu. attribute", i);
TRACE1(", converting %d. attribute", i);
(*ckpArray)[i] = jAttributeToCKAttribute(env, jAttribute); (*ckpArray)[i] = jAttributeToCKAttribute(env, jAttribute);
if ((*env)->ExceptionCheck(env)) { if ((*env)->ExceptionCheck(env)) {
freeCKAttributeArray(*ckpArray, i); freeCKAttributeArray(*ckpArray, i);
@ -1116,7 +1115,7 @@ CK_VOID_PTR jObjectToPrimitiveCKObjectPtr(JNIEnv *env, jobject jObject, CK_ULONG
if ((*env)->IsInstanceOf(env, jObject, jLongClass)) { if ((*env)->IsInstanceOf(env, jObject, jLongClass)) {
ckpObject = jLongObjectToCKULongPtr(env, jObject); ckpObject = jLongObjectToCKULongPtr(env, jObject);
*ckpLength = sizeof(CK_ULONG); *ckpLength = sizeof(CK_ULONG);
TRACE1("<converted long value %X>", *((CK_ULONG *) ckpObject)); TRACE1("<converted long value %lu>", *((CK_ULONG *) ckpObject));
return ckpObject; return ckpObject;
} }
@ -1126,7 +1125,7 @@ CK_VOID_PTR jObjectToPrimitiveCKObjectPtr(JNIEnv *env, jobject jObject, CK_ULONG
ckpObject = jBooleanObjectToCKBBoolPtr(env, jObject); ckpObject = jBooleanObjectToCKBBoolPtr(env, jObject);
*ckpLength = sizeof(CK_BBOOL); *ckpLength = sizeof(CK_BBOOL);
TRACE0(" <converted boolean value "); TRACE0(" <converted boolean value ");
TRACE0((*((CK_BBOOL *) ckpObjectPtr) == TRUE) ? "TRUE>" : "FALSE>"); TRACE0((*((CK_BBOOL *) ckpObject) == TRUE) ? "TRUE>" : "FALSE>");
return ckpObject; return ckpObject;
} }
@ -1177,7 +1176,7 @@ CK_VOID_PTR jObjectToPrimitiveCKObjectPtr(JNIEnv *env, jobject jObject, CK_ULONG
if ((*env)->IsInstanceOf(env, jObject, jIntegerClass)) { if ((*env)->IsInstanceOf(env, jObject, jIntegerClass)) {
ckpObject = jIntegerObjectToCKULongPtr(env, jObject); ckpObject = jIntegerObjectToCKULongPtr(env, jObject);
*ckpLength = sizeof(CK_ULONG); *ckpLength = sizeof(CK_ULONG);
TRACE1("<converted integer value %X>", *((CK_ULONG *) ckpObject)); TRACE1("<converted integer value %lu>", *((CK_ULONG *) ckpObject));
return ckpObject; return ckpObject;
} }