From: Daniel Stenberg Date: Tue, 22 Apr 2014 21:24:31 +0000 (+0200) Subject: gtls: fix NULL pointer dereference X-Git-Tag: curl-7_37_0~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=386ed2d590;p=thirdparty%2Fcurl.git gtls: fix NULL pointer dereference gnutls_x509_crt_import() must not be called with a NULL certificate Bug: http://curl.haxx.se/mail/lib-2014-04/0145.html Reported-by: Damian Dixon --- diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index 2a98787159..d6849cebc6 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -735,9 +735,10 @@ gtls_connect_step3(struct connectdata *conn, /* initialize an X.509 certificate structure. */ gnutls_x509_crt_init(&x509_cert); - /* convert the given DER or PEM encoded Certificate to the native - gnutls_x509_crt_t format */ - gnutls_x509_crt_import(x509_cert, chainp, GNUTLS_X509_FMT_DER); + if(chainp) + /* convert the given DER or PEM encoded Certificate to the native + gnutls_x509_crt_t format */ + gnutls_x509_crt_import(x509_cert, chainp, GNUTLS_X509_FMT_DER); if(data->set.ssl.issuercert) { gnutls_x509_crt_init(&x509_issuer);