From 890ac04a0b4b6b6c5e3632de63ac844729f549dc Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sun, 3 Aug 2008 22:05:56 +0200 Subject: Fix mem allocation in config initialization. Signed-off-by: Matt Colyer --- src/initconf.c | 13 ++++++++----- src/userpref.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/initconf.c b/src/initconf.c index de583fa..7d6aa28 100644 --- a/src/initconf.c +++ b/src/initconf.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { gnutls_global_init(); - char* host_id = NULL; + char* host_id = "29942970-207913891623273984"; gnutls_x509_privkey_t root_privkey; gnutls_x509_privkey_t host_privkey; @@ -42,9 +42,12 @@ int main(int argc, char *argv[]) { gnutls_x509_crt_init(&root_cert); gnutls_x509_crt_init(&host_cert); + /* generate HostID */ + //TODO + /* generate keys */ - int ret1 = gnutls_x509_privkey_generate(root_privkey, GNUTLS_PK_RSA, 2048, 0); - int ret2 = gnutls_x509_privkey_generate(host_privkey, GNUTLS_PK_RSA, 2048, 0); + gnutls_x509_privkey_generate(root_privkey, GNUTLS_PK_RSA, 2048, 0); + gnutls_x509_privkey_generate(host_privkey, GNUTLS_PK_RSA, 2048, 0); /* generate certificates */ gnutls_x509_crt_set_key(root_cert, root_privkey); @@ -73,7 +76,7 @@ int main(int argc, char *argv[]) { gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, NULL, &host_key_pem.size); root_key_pem.data = gnutls_malloc(root_key_pem.size); - root_key_pem.data = gnutls_malloc(root_key_pem.size); + host_key_pem.data = gnutls_malloc(host_key_pem.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); @@ -85,7 +88,7 @@ int main(int argc, char *argv[]) { gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, NULL, &host_cert_pem.size); root_cert_pem.data = gnutls_malloc(root_cert_pem.size); - root_cert_pem.data = gnutls_malloc(root_cert_pem.size); + host_cert_pem.data = gnutls_malloc(host_cert_pem.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); diff --git a/src/userpref.c b/src/userpref.c index 399e054..f93cff4 100644 --- a/src/userpref.c +++ b/src/userpref.c @@ -237,7 +237,7 @@ char* get_host_certificate() int init_config_file(char* host_id, char* root_private_key, char* host_private_key, char* root_cert, char* host_cert) { - if (!host_id || !root_private_key || !host_private_key) + if (!host_id || !root_private_key || !host_private_key || !root_cert || !host_cert) return 0; gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL); -- cgit v1.1-32-gdbae