Check the return code from ASN1_TIME_diff()
authorMatt Caswell <matt@openssl.org>
Mon, 12 Feb 2018 17:47:50 +0000 (17:47 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 15 Feb 2018 15:29:39 +0000 (15:29 +0000)
The function can fail so we should check the return code.

Found by Coverity

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5339)

(cherry picked from commit 0d502c3511ab3b1c8acb129fb3af836727b8092d)

apps/ca.c

index efa2ca84e36bf0c888cfad0e7c48c71b94a91437..26ca6bb5d2e6fe3a6acd708f379e23299c29314c 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1711,7 +1711,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
 
     if (enddate != NULL) {
         int tdays;
-        ASN1_TIME_diff(&tdays, NULL, NULL, X509_get0_notAfter(ret));
+
+        if (!ASN1_TIME_diff(&tdays, NULL, NULL, X509_get0_notAfter(ret)))
+            goto end;
         days = tdays;
     }