Add some sanity checks when checking CRL scores
authorMatt Caswell <matt@openssl.org>
Mon, 22 Aug 2016 23:01:57 +0000 (00:01 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 26 Sep 2016 08:19:50 +0000 (09:19 +0100)
Note: this was accidentally omitted from OpenSSL 1.0.2 branch.
Without this fix any attempt to use CRLs will crash.

CVE-2016-7052

Thanks to Bruce Stephens and Thomas Jakobi for reporting this issue.

Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/x509/x509_vfy.c

index 8334b3fcff7fb2a92fba494c38ef598b08c2f8a6..b1472018baf75c9efc0e7e8e1f3648d298bc4609 100644 (file)
@@ -1124,10 +1124,10 @@ static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
         crl = sk_X509_CRL_value(crls, i);
         reasons = *preasons;
         crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
-        if (crl_score < best_score)
+        if (crl_score < best_score || crl_score == 0)
             continue;
         /* If current CRL is equivalent use it if it is newer */
-        if (crl_score == best_score) {
+        if (crl_score == best_score && best_crl != NULL) {
             int day, sec;
             if (ASN1_TIME_diff(&day, &sec, X509_CRL_get_lastUpdate(best_crl),
                                X509_CRL_get_lastUpdate(crl)) == 0)