]> git.0d.be Git - empathy.git/commitdiff
Make sure we allocate the right size for certificates
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 8 Sep 2010 14:57:49 +0000 (16:57 +0200)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 8 Sep 2010 14:57:49 +0000 (16:57 +0200)
libempathy/empathy-tls-certificate.c

index f36887dcd37998e6bdfcc63d49437dc1e5b1111f..826608fad8b5d06fab945b306ad78d65122a00e2 100644 (file)
@@ -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;