summaryrefslogtreecommitdiff
path: root/gio/gtlscertificate.c
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2015-08-28 19:43:09 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2015-08-29 08:43:29 -0500
commit587068c969716df2b994362e3133c68d91455d47 (patch)
treeef9e73cc1a96eec33fd35f2c537a242736c32c65 /gio/gtlscertificate.c
parent1ab3e3ed3e0c50cc8e747a9617f9412af8a15bdd (diff)
downloadglib-587068c969716df2b994362e3133c68d91455d47.tar.gz
GTlsCertificate: fix loading of chain with private key
If a private key (or anything, in fact) follows the final certificate in the file, certificate parsing will be aborted and only the first certificate in the chain will be returned, with the private key not set. Be tolerant of this, rather than expecting the final character in the file to be the newline following the last certificate. https://bugzilla.gnome.org/show_bug.cgi?id=754264
Diffstat (limited to 'gio/gtlscertificate.c')
-rw-r--r--gio/gtlscertificate.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gio/gtlscertificate.c b/gio/gtlscertificate.c
index b3d0c2c97..d7dff70fc 100644
--- a/gio/gtlscertificate.c
+++ b/gio/gtlscertificate.c
@@ -335,13 +335,19 @@ parse_and_create_certificate_list (const gchar *data,
while (p && *p)
{
gchar *cert_pem;
+ GError *error = NULL;
- cert_pem = parse_next_pem_certificate (&p, end, FALSE, NULL);
- if (!cert_pem)
+ cert_pem = parse_next_pem_certificate (&p, end, FALSE, &error);
+ if (error)
{
g_slist_free_full (pem_list, g_free);
+ g_error_free (error);
return first_pem_list;
}
+ else if (!cert_pem)
+ {
+ break;
+ }
pem_list = g_slist_prepend (pem_list, cert_pem);
}