summaryrefslogtreecommitdiffstats
path: root/src/lockdown.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-07-28 14:59:07 +0200
committerGravatar Matt Colyer2009-07-28 21:31:25 -0700
commitc57ebf917e30afd78dac8042552966811531c632 (patch)
tree5c3e200bc1babfead1900dde7d1d37400fac498c /src/lockdown.c
parentdd97a88597eb00fa688ee9f28cadac117c47f6f0 (diff)
downloadlibimobiledevice-c57ebf917e30afd78dac8042552966811531c632.tar.gz
libimobiledevice-c57ebf917e30afd78dac8042552966811531c632.tar.bz2
Fix potential memory corruption in calls to gnutls function on 64 bit arch
[#60 state:resolved] Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/lockdown.c')
-rw-r--r--src/lockdown.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index bc430c9..88ab7b0 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -954,10 +954,12 @@ lockdownd_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datu
if (LOCKDOWN_E_SUCCESS == ret) {
/* if everything went well, export in PEM format */
+ size_t export_size = 0;
gnutls_datum_t dev_pem = { NULL, 0 };
- gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, NULL, &dev_pem.size);
- dev_pem.data = gnutls_malloc(dev_pem.size);
- gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, dev_pem.data, &dev_pem.size);
+ gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, NULL, &export_size);
+ dev_pem.data = gnutls_malloc(export_size);
+ gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, dev_pem.data, &export_size);
+ dev_pem.size = export_size;
gnutls_datum_t pem_root_cert = { NULL, 0 };
gnutls_datum_t pem_host_cert = { NULL, 0 };