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;
|
||||
FileList fl = FileList_new(16);
|
||||
WildcardIterator it = WildcardIterator_for(wildcard);
|
||||
|
||||
if (it == NULL)
|
||||
{
|
||||
FileList_free(fl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((basename = WildcardIterator_next(it)) != NULL)
|
||||
if (isJarFileName(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,
|
||||
jint type, void *result) {
|
||||
OM_uint32 minor, major=GSS_C_QOP_DEFAULT;
|
||||
OM_uint32 minor, major=0;
|
||||
OM_uint32 routineErr;
|
||||
gss_cred_id_t credHdl;
|
||||
|
||||
|
@ -112,22 +112,34 @@ CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject jInitArgs)
|
||||
ckpInitArgs->UnlockMutex = NULL_PTR;
|
||||
#else
|
||||
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);
|
||||
ckpInitArgs->CreateMutex = (jMutexHandler != NULL) ? &callJCreateMutex : NULL_PTR;
|
||||
|
||||
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);
|
||||
ckpInitArgs->DestroyMutex = (jMutexHandler != NULL) ? &callJDestroyMutex : NULL_PTR;
|
||||
|
||||
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);
|
||||
ckpInitArgs->LockMutex = (jMutexHandler != NULL) ? &callJLockMutex : NULL_PTR;
|
||||
|
||||
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);
|
||||
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 */
|
||||
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);
|
||||
ckpInitArgs->flags = jLongToCKULong(jFlags);
|
||||
|
||||
/* pReserved should be NULL_PTR in this version */
|
||||
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);
|
||||
|
||||
/* 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");
|
||||
|
||||
if (mustsetenv == JNI_FALSE) {
|
||||
JLI_MemFree(newargv);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
JLI_MemFree(newargv);
|
||||
return;
|
||||
#endif /* SETENV_REQUIRED */
|
||||
} else { /* do the same speculatively or exit */
|
||||
|
Loading…
x
Reference in New Issue
Block a user