8181670: Improve implementation of keystores

Reviewed-by: mullan
This commit is contained in:
Vinnie Ryan 2017-09-05 15:53:33 +01:00
parent de7e845521
commit 143cb6a2d2

View file

@ -439,6 +439,11 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
goto errOut;
}
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
// clear the password and release
memset(passwordChars, 0, passwordLen);
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
JNI_ABORT);
}
}
@ -527,8 +532,19 @@ JNF_COCOA_ENTER(env);
if (passwordObj) {
passwordLen = (*env)->GetArrayLength(env, passwordObj);
passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL);
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
if (passwordLen > 0) {
passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL);
if (passwordChars == NULL) {
goto errOut;
}
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
// clear the password and release
memset(passwordChars, 0, passwordLen);
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
JNI_ABORT);
}
}
paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;