8000476: Memory Leaks and uninitialized memory access in PKCS11 and other native code
Reviewed-by: dsamersoff, valeriep, chegar
This commit is contained in:
parent
c94385feb8
commit
0bb98e7294
@ -356,8 +356,13 @@ wildcardFileList(const char *wildcard)
|
|||||||
const char *basename;
|
const char *basename;
|
||||||
FileList fl = FileList_new(16);
|
FileList fl = FileList_new(16);
|
||||||
WildcardIterator it = WildcardIterator_for(wildcard);
|
WildcardIterator it = WildcardIterator_for(wildcard);
|
||||||
|
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
|
{
|
||||||
|
FileList_free(fl);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while ((basename = WildcardIterator_next(it)) != NULL)
|
while ((basename = WildcardIterator_next(it)) != NULL)
|
||||||
if (isJarFileName(basename))
|
if (isJarFileName(basename))
|
||||||
FileList_add(fl, wildcardConcat(wildcard, basename));
|
FileList_add(fl, wildcardConcat(wildcard, basename));
|
||||||
|
@ -571,7 +571,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_releaseCred(JNIEnv *env,
|
|||||||
*/
|
*/
|
||||||
void inquireCred(JNIEnv *env, jobject jobj, gss_cred_id_t pCred,
|
void inquireCred(JNIEnv *env, jobject jobj, gss_cred_id_t pCred,
|
||||||
jint type, void *result) {
|
jint type, void *result) {
|
||||||
OM_uint32 minor, major=GSS_C_QOP_DEFAULT;
|
OM_uint32 minor, major=0;
|
||||||
OM_uint32 routineErr;
|
OM_uint32 routineErr;
|
||||||
gss_cred_id_t credHdl;
|
gss_cred_id_t credHdl;
|
||||||
|
|
||||||
|
@ -112,22 +112,34 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
|
|||||||
ckpInitArgs->UnlockMutex = NULL_PTR;
|
ckpInitArgs->UnlockMutex = NULL_PTR;
|
||||||
#else
|
#else
|
||||||
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "CreateMutex", "Lsun/security/pkcs11/wrapper/CK_CREATEMUTEX;");
|
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "CreateMutex", "Lsun/security/pkcs11/wrapper/CK_CREATEMUTEX;");
|
||||||
if (fieldID == NULL) { return NULL; }
|
if (fieldID == NULL) {
|
||||||
|
free(ckpInitArgs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
||||||
ckpInitArgs->CreateMutex = (jMutexHandler != NULL) ? &callJCreateMutex : NULL_PTR;
|
ckpInitArgs->CreateMutex = (jMutexHandler != NULL) ? &callJCreateMutex : NULL_PTR;
|
||||||
|
|
||||||
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "DestroyMutex", "Lsun/security/pkcs11/wrapper/CK_DESTROYMUTEX;");
|
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "DestroyMutex", "Lsun/security/pkcs11/wrapper/CK_DESTROYMUTEX;");
|
||||||
if (fieldID == NULL) { return NULL; }
|
if (fieldID == NULL) {
|
||||||
|
free(ckpInitArgs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
||||||
ckpInitArgs->DestroyMutex = (jMutexHandler != NULL) ? &callJDestroyMutex : NULL_PTR;
|
ckpInitArgs->DestroyMutex = (jMutexHandler != NULL) ? &callJDestroyMutex : NULL_PTR;
|
||||||
|
|
||||||
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "LockMutex", "Lsun/security/pkcs11/wrapper/CK_LOCKMUTEX;");
|
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "LockMutex", "Lsun/security/pkcs11/wrapper/CK_LOCKMUTEX;");
|
||||||
if (fieldID == NULL) { return NULL; }
|
if (fieldID == NULL) {
|
||||||
|
free(ckpInitArgs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
||||||
ckpInitArgs->LockMutex = (jMutexHandler != NULL) ? &callJLockMutex : NULL_PTR;
|
ckpInitArgs->LockMutex = (jMutexHandler != NULL) ? &callJLockMutex : NULL_PTR;
|
||||||
|
|
||||||
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "UnlockMutex", "Lsun/security/pkcs11/wrapper/CK_UNLOCKMUTEX;");
|
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "UnlockMutex", "Lsun/security/pkcs11/wrapper/CK_UNLOCKMUTEX;");
|
||||||
if (fieldID == NULL) { return NULL; }
|
if (fieldID == NULL) {
|
||||||
|
free(ckpInitArgs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
jMutexHandler = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
||||||
ckpInitArgs->UnlockMutex = (jMutexHandler != NULL) ? &callJUnlockMutex : NULL_PTR;
|
ckpInitArgs->UnlockMutex = (jMutexHandler != NULL) ? &callJUnlockMutex : NULL_PTR;
|
||||||
|
|
||||||
@ -151,13 +163,19 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
|
|||||||
|
|
||||||
/* convert and set the flags field */
|
/* convert and set the flags field */
|
||||||
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "flags", "J");
|
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "flags", "J");
|
||||||
if (fieldID == NULL) { return NULL; }
|
if (fieldID == NULL) {
|
||||||
|
free(ckpInitArgs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
jFlags = (*env)->GetLongField(env, jInitArgs, fieldID);
|
jFlags = (*env)->GetLongField(env, jInitArgs, fieldID);
|
||||||
ckpInitArgs->flags = jLongToCKULong(jFlags);
|
ckpInitArgs->flags = jLongToCKULong(jFlags);
|
||||||
|
|
||||||
/* pReserved should be NULL_PTR in this version */
|
/* pReserved should be NULL_PTR in this version */
|
||||||
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "pReserved", "Ljava/lang/Object;");
|
fieldID = (*env)->GetFieldID(env, jInitArgsClass, "pReserved", "Ljava/lang/Object;");
|
||||||
if (fieldID == NULL) { return NULL; }
|
if (fieldID == NULL) {
|
||||||
|
free(ckpInitArgs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
jReserved = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
jReserved = (*env)->GetObjectField(env, jInitArgs, fieldID);
|
||||||
|
|
||||||
/* we try to convert the reserved parameter also */
|
/* we try to convert the reserved parameter also */
|
||||||
|
@ -478,9 +478,11 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
|||||||
JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
|
JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
|
||||||
|
|
||||||
if (mustsetenv == JNI_FALSE) {
|
if (mustsetenv == JNI_FALSE) {
|
||||||
|
JLI_MemFree(newargv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
JLI_MemFree(newargv);
|
||||||
return;
|
return;
|
||||||
#endif /* SETENV_REQUIRED */
|
#endif /* SETENV_REQUIRED */
|
||||||
} else { /* do the same speculatively or exit */
|
} else { /* do the same speculatively or exit */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user