[empathy] Make sure we allocate the right size for certificates



commit 366d36a10c2e88306fa2d556570e3def1b0149d6
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Sep 8 16:57:49 2010 +0200

    Make sure we allocate the right size for certificates

 libempathy/empathy-tls-certificate.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/libempathy/empathy-tls-certificate.c b/libempathy/empathy-tls-certificate.c
index f36887d..826608f 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]