summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-08-12 12:05:22 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2011-08-15 11:22:47 +0200
commitd7d0a3a98ef24a7be944c54c278f04c59a60974b (patch)
treed5f5050c0877c45c0218e6261daa2e85ccf83368 /client
parent855f2ed2ac6a67e88d6f6626641af508b887cd4b (diff)
downloadspice-d7d0a3a98ef24a7be944c54c278f04c59a60974b.tar.gz
spice-d7d0a3a98ef24a7be944c54c278f04c59a60974b.tar.xz
spice-d7d0a3a98ef24a7be944c54c278f04c59a60974b.zip
channel: fix EVP_PKEY leak
Diffstat (limited to 'client')
-rw-r--r--client/red_channel.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/client/red_channel.cpp b/client/red_channel.cpp
index 5f8bd25d..8632600c 100644
--- a/client/red_channel.cpp
+++ b/client/red_channel.cpp
@@ -71,10 +71,7 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
uint32_t link_res;
uint32_t i;
- EVP_PKEY *pubkey;
- int nRSASize;
BIO *bioKey;
- RSA *rsa;
uint8_t *buffer, *p;
uint32_t expected_major;
@@ -171,6 +168,10 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
bioKey = BIO_new(BIO_s_mem());
if (bioKey != NULL) {
+ EVP_PKEY *pubkey;
+ int nRSASize;
+ RSA *rsa;
+
BIO_write(bioKey, reply->pub_key, SPICE_TICKET_PUBKEY_BYTES);
pubkey = d2i_PUBKEY_bio(bioKey, NULL);
rsa = pubkey->pkey.rsa;
@@ -186,10 +187,13 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
rsa, RSA_PKCS1_OAEP_PADDING) > 0) {
send((uint8_t*)bufEncrypted.get(), nRSASize);
} else {
+ EVP_PKEY_free(pubkey);
+ BIO_free(bioKey);
THROW("could not encrypt password");
}
memset(bufEncrypted.get(), 0, nRSASize);
+ EVP_PKEY_free(pubkey);
} else {
THROW("Could not initiate BIO");
}