diff options
| author | 2009-07-29 08:33:48 +0200 | |
|---|---|---|
| committer | 2009-07-29 08:33:48 +0200 | |
| commit | bcf67a0cfa12fabd49bb719ce960dfdcf74a1487 (patch) | |
| tree | d73d30855c0994b87a37adfa39984f5cdf18a9c9 | |
| parent | e78569c49026ae52311e33f9f6cd45cb6ddc5f2c (diff) | |
| parent | 4a5d3174ddc5a9596191176829f0b8ae1feae32b (diff) | |
| download | libimobiledevice-bcf67a0cfa12fabd49bb719ce960dfdcf74a1487.tar.gz libimobiledevice-bcf67a0cfa12fabd49bb719ce960dfdcf74a1487.tar.bz2 | |
Merge branch 'master' of git://github.com/MattColyer/libiphone into martin
| -rw-r--r-- | src/lockdown.c | 8 | ||||
| -rw-r--r-- | src/userpref.c | 32 | 
2 files changed, 25 insertions, 15 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 }; diff --git a/src/userpref.c b/src/userpref.c index 4b6dd98..b930693 100644 --- a/src/userpref.c +++ b/src/userpref.c @@ -289,29 +289,37 @@ static userpref_error_t userpref_gen_keys_and_cert(void)  	gnutls_x509_crt_sign(host_cert, root_cert, root_privkey);  	/* export to PEM format */ +	size_t root_key_export_size = 0; +	size_t host_key_export_size = 0;  	gnutls_datum_t root_key_pem = { NULL, 0 };  	gnutls_datum_t host_key_pem = { NULL, 0 }; -	gnutls_x509_privkey_export(root_privkey, GNUTLS_X509_FMT_PEM, NULL, &root_key_pem.size); -	gnutls_x509_privkey_export(host_privkey, GNUTLS_X509_FMT_PEM, NULL, &host_key_pem.size); +	gnutls_x509_privkey_export(root_privkey, GNUTLS_X509_FMT_PEM, NULL, &root_key_export_size); +	gnutls_x509_privkey_export(host_privkey, GNUTLS_X509_FMT_PEM, NULL, &host_key_export_size); -	root_key_pem.data = gnutls_malloc(root_key_pem.size); -	host_key_pem.data = gnutls_malloc(host_key_pem.size); +	root_key_pem.data = gnutls_malloc(root_key_export_size); +	host_key_pem.data = gnutls_malloc(host_key_export_size); -	gnutls_x509_privkey_export(root_privkey, GNUTLS_X509_FMT_PEM, root_key_pem.data, &root_key_pem.size); -	gnutls_x509_privkey_export(host_privkey, GNUTLS_X509_FMT_PEM, host_key_pem.data, &host_key_pem.size); +	gnutls_x509_privkey_export(root_privkey, GNUTLS_X509_FMT_PEM, root_key_pem.data, &root_key_export_size); +	root_key_pem.size = root_key_export_size; +	gnutls_x509_privkey_export(host_privkey, GNUTLS_X509_FMT_PEM, host_key_pem.data, &host_key_export_size); +	host_key_pem.size = host_key_export_size; +	size_t root_cert_export_size = 0; +	size_t host_cert_export_size = 0;  	gnutls_datum_t root_cert_pem = { NULL, 0 };  	gnutls_datum_t host_cert_pem = { NULL, 0 }; -	gnutls_x509_crt_export(root_cert, GNUTLS_X509_FMT_PEM, NULL, &root_cert_pem.size); -	gnutls_x509_crt_export(host_cert, GNUTLS_X509_FMT_PEM, NULL, &host_cert_pem.size); +	gnutls_x509_crt_export(root_cert, GNUTLS_X509_FMT_PEM, NULL, &root_cert_export_size); +	gnutls_x509_crt_export(host_cert, GNUTLS_X509_FMT_PEM, NULL, &host_cert_export_size); -	root_cert_pem.data = gnutls_malloc(root_cert_pem.size); -	host_cert_pem.data = gnutls_malloc(host_cert_pem.size); +	root_cert_pem.data = gnutls_malloc(root_cert_export_size); +	host_cert_pem.data = gnutls_malloc(host_cert_export_size); -	gnutls_x509_crt_export(root_cert, GNUTLS_X509_FMT_PEM, root_cert_pem.data, &root_cert_pem.size); -	gnutls_x509_crt_export(host_cert, GNUTLS_X509_FMT_PEM, host_cert_pem.data, &host_cert_pem.size); +	gnutls_x509_crt_export(root_cert, GNUTLS_X509_FMT_PEM, root_cert_pem.data, &root_cert_export_size); +	root_cert_pem.size = root_cert_export_size; +	gnutls_x509_crt_export(host_cert, GNUTLS_X509_FMT_PEM, host_cert_pem.data, &host_cert_export_size); +	host_cert_pem.size = host_cert_export_size;  	if (NULL != root_cert_pem.data && 0 != root_cert_pem.size &&  		NULL != host_cert_pem.data && 0 != host_cert_pem.size) | 
