From 366d36a10c2e88306fa2d556570e3def1b0149d6 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 8 Sep 2010 16:57:49 +0200 Subject: Make sure we allocate the right size for certificates --- libempathy/empathy-tls-certificate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tls-certificate.c b/libempathy/empathy-tls-certificate.c index f36887dcd..826608fad 100644 --- a/libempathy/empathy-tls-certificate.c +++ b/libempathy/empathy-tls-certificate.c @@ -426,16 +426,16 @@ empathy_tls_certificate_reject_finish (EmpathyTLSCertificate *self, static gsize get_exported_size (gnutls_x509_crt_t cert) { - gsize retval; - guchar fake; + gsize retval = 2; + guchar fake[2] = { 0, 0 }; /* fake an export so we get the size to allocate */ gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_PEM, - &fake, &retval); + fake, &retval); DEBUG ("Should allocate %lu bytes", (gulong) retval); - return retval; + return retval + 1; } void @@ -484,7 +484,8 @@ empathy_tls_certificate_store_ca (EmpathyTLSCertificate *self) if (res < 0) { - DEBUG ("Failed to export the CA certificate; GnuTLS returned %d", res); + DEBUG ("Failed to export the CA certificate; GnuTLS returned %d," + "and should be %lu bytes long", res, (gulong) exported_len); gnutls_x509_crt_deinit (cert); goto out; -- cgit v1.2.3