aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2011-09-06 18:17:38 +0200
committerKamil Dudka <kdudka@redhat.com>2011-10-17 12:13:44 +0200
commit491c5a497cc4cab0a488a0c94eec7d518d57d304 (patch)
treef72d8cf094105665d8867ba42e9c4c728ffa8bd0
parent06e6755e874557e5111e439cfb4ad0249673a90c (diff)
nss: avoid a SIGSEGV with immature version of NSS
Bug: https://bugzilla.redhat.com/733685
-rw-r--r--lib/nss.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/nss.c b/lib/nss.c
index 25293d5a5..f63d9718b 100644
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -382,7 +382,29 @@ static CURLcode nss_load_cert(struct ssl_connect_data *ssl,
/* libnsspem.so leaks memory if the requested file does not exist. For more
* details, go to <https://bugzilla.redhat.com/734760>. */
if(is_file(filename))
- return nss_create_object(ssl, CKO_CERTIFICATE, filename, cacert);
+ err = nss_create_object(ssl, CKO_CERTIFICATE, filename, cacert);
+
+ if(CURLE_OK == err && !cacert) {
+ /* we have successfully loaded a client certificate */
+ CERTCertificate *cert;
+ char *nickname = NULL;
+ char *n = strrchr(filename, '/');
+ if(n)
+ n++;
+
+ /* The following undocumented magic helps to avoid a SIGSEGV on call
+ * of PK11_ReadRawAttribute() from SelectClientCert() when using an
+ * immature version of libnsspem.so. For more details, go to
+ * <https://bugzilla.redhat.com/733685>. */
+ nickname = aprintf("PEM Token #1:%s", n);
+ if(nickname) {
+ cert = PK11_FindCertFromNickname(nickname, NULL);
+ if(cert)
+ CERT_DestroyCertificate(cert);
+
+ free(nickname);
+ }
+ }
#endif
return err;