summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2012-08-01 08:51:57 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-01 08:51:57 -0700
commit989bedd47eaa82007d6b702936efe75c7ecefc52 (patch)
tree43477d98b8f8a17de2c3a53513ea47eb120dee63
parent040b460e46099873d7cdee56e55ed5423f19bf72 (diff)
parent1f9fe21b93f1d1ee44a325629a05ee4f476e5f6a (diff)
am 1f9fe21b: Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey
* commit '1f9fe21b93f1d1ee44a325629a05ee4f476e5f6a': Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey
-rw-r--r--luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
index 7dabc5d7c9..ba2a040f03 100644
--- a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
+++ b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
@@ -2698,6 +2698,10 @@ static void NativeCrypto_SSL_use_OpenSSL_PrivateKey(JNIEnv* env, jclass, jint ss
JNI_TRACE("ssl=%p SSL_use_OpenSSL_PrivateKey => error", ssl);
return;
}
+ // SSL_use_PrivateKey expects to take ownership of the EVP_PKEY,
+ // but we have an external reference from the caller such as an
+ // OpenSSLKey, so we manually increment the reference count here.
+ CRYPTO_add(&pkey->references,+1,CRYPTO_LOCK_EVP_PKEY);
JNI_TRACE("ssl=%p SSL_use_OpenSSL_PrivateKey => ok", ssl);
}