summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2013-06-30 20:33:42 -0400
committerGravatar Aaron Burghardt2013-06-30 21:26:36 -0400
commit62349d85b5fb39e1dc61974b38594c7f0d58c29b (patch)
tree06dd2b8909dc3f3758c810ba6f8c521401fbb263
parenta124ee348d7862eaa2eb834246d2b74e3c68b518 (diff)
downloadlibimobiledevice-62349d85b5fb39e1dc61974b38594c7f0d58c29b.tar.gz
libimobiledevice-62349d85b5fb39e1dc61974b38594c7f0d58c29b.tar.bz2
Fixed memory leak in lockdownd_gen_pair_cert() when getting cert data using OpenSSL.
-rw-r--r--src/lockdown.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index 1319e5d..21aa334 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -1213,10 +1213,13 @@ lockdownd_error_t lockdownd_gen_pair_cert(key_data_t public_key, key_data_t * od
/* copy buffer for output */
membp = BIO_new(BIO_s_mem());
if (membp && PEM_write_bio_X509(membp, dev_cert) > 0) {
- odevice_cert->size = BIO_get_mem_data(membp, &odevice_cert->data);
+ void *datap;
+ odevice_cert->size = BIO_get_mem_data(membp, &datap);
+ odevice_cert->data = malloc(odevice_cert->size);
+ memcpy(odevice_cert->data, datap, odevice_cert->size);
}
if (membp)
- free(membp);
+ BIO_free(membp);
ohost_cert->data = malloc(pem_host_cert.size);
memcpy(ohost_cert->data, pem_host_cert.data, pem_host_cert.size);