CT: check some GeneralizedTime return values
authorBenjamin Kaduk <bkaduk@akamai.com>
Tue, 8 Mar 2016 21:53:49 +0000 (15:53 -0600)
committerRich Salz <rsalz@akamai.com>
Thu, 10 Mar 2016 01:52:19 +0000 (20:52 -0500)
Some of the ASN.1 routines for the GeneralizedTime type can return
errors; check for these and do not continue past failure, so as
to appease coverity.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/ct/ct_prn.c

index bb669d577a53d6f567b9b22b46124fdff4faace1..c2e11b1e24083d91acf6f424552b1e12311365f8 100644 (file)
@@ -80,6 +80,8 @@ static void timestamp_print(uint64_t timestamp, BIO *out)
     ASN1_GENERALIZEDTIME *gen = ASN1_GENERALIZEDTIME_new();
     char genstr[20];
 
+    if (gen == NULL)
+        return;
     ASN1_GENERALIZEDTIME_adj(gen, (time_t)0,
                              (int)(timestamp / 86400000),
                              (timestamp % 86400000) / 1000);
@@ -89,8 +91,8 @@ static void timestamp_print(uint64_t timestamp, BIO *out)
      */
     BIO_snprintf(genstr, sizeof(genstr), "%.14s.%03dZ",
                  ASN1_STRING_data(gen), (unsigned int)(timestamp % 1000));
-    ASN1_GENERALIZEDTIME_set_string(gen, genstr);
-    ASN1_GENERALIZEDTIME_print(out, gen);
+    if (ASN1_GENERALIZEDTIME_set_string(gen, genstr))
+        ASN1_GENERALIZEDTIME_print(out, gen);
     ASN1_GENERALIZEDTIME_free(gen);
 }