提交 2c28329b 编写于 作者: I igerasim

8181670: Improve implementation of keystores

Reviewed-by: mullan
上级 81304e02
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -432,6 +432,11 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa ...@@ -432,6 +432,11 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
goto errOut; goto errOut;
} }
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen); passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
// clear the password and release
memset(passwordChars, 0, passwordLen);
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
JNI_ABORT);
} }
} }
...@@ -518,8 +523,19 @@ JNF_COCOA_ENTER(env); ...@@ -518,8 +523,19 @@ JNF_COCOA_ENTER(env);
if (passwordObj) { if (passwordObj) {
passwordLen = (*env)->GetArrayLength(env, 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; paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册