[glib/glib-2-40] gtlscertificate: fix certificate list parsing with trailing comments



commit a36ed2715670b35b2718e8ffe0493d9d921e55b5
Author: Dan Winship <danw gnome org>
Date:   Wed Apr 9 10:39:45 2014 -0400

    gtlscertificate: fix certificate list parsing with trailing comments
    
    g_tls_certificate_list_new_from_file() was supposed to ignore non-PEM
    content, but it accidentally required that there not be anything after
    the last certificate. Fix that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727692

 gio/gtlscertificate.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/gio/gtlscertificate.c b/gio/gtlscertificate.c
index a532fe5..47de03d 100644
--- a/gio/gtlscertificate.c
+++ b/gio/gtlscertificate.c
@@ -476,19 +476,24 @@ g_tls_certificate_list_new_from_file (const gchar  *file,
     {
       gchar *cert_pem;
       GTlsCertificate *cert = NULL;
+      GError *parse_error = NULL;
 
-      cert_pem = parse_next_pem_certificate (&p, end, FALSE, error);
+      cert_pem = parse_next_pem_certificate (&p, end, FALSE, &parse_error);
       if (cert_pem)
-       {
-         cert = g_tls_certificate_new_internal (cert_pem, NULL, error);
-         g_free (cert_pem);
-       }
+        {
+          cert = g_tls_certificate_new_internal (cert_pem, NULL, &parse_error);
+          g_free (cert_pem);
+        }
       if (!cert)
-       {
-         g_list_free_full (queue.head, g_object_unref);
-         queue.head = NULL;
-         break;
-       }
+        {
+          if (parse_error)
+            {
+              g_propagate_error (error, parse_error);
+              g_list_free_full (queue.head, g_object_unref);
+              queue.head = NULL;
+            }
+          break;
+        }
       g_queue_push_tail (&queue, cert);
     }
 


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