Limit depth of nested sequences when generating ASN.1
[openssl.git] / crypto / asn1 / a_utctm.c
index 9b552849f028bc0805046beb7cbcd8023801f342..0e2f1b0c40b506c2331536ac15f8ba9ef5b5139e 100644 (file)
@@ -193,11 +193,11 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
     int free_s = 0;
 
     if (s == NULL) {
+        s = ASN1_UTCTIME_new();
+        if (s == NULL)
+            goto err;
         free_s = 1;
-        s = M_ASN1_UTCTIME_new();
     }
-    if (s == NULL)
-        goto err;
 
     ts = OPENSSL_gmtime(&t, &data);
     if (ts == NULL)
@@ -233,8 +233,8 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
 #endif
     return (s);
  err:
-    if (free_s && s)
-        M_ASN1_UTCTIME_free(s);
+    if (free_s)
+        ASN1_UTCTIME_free(s);
     return NULL;
 }
 
@@ -249,7 +249,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
     if (!OPENSSL_gmtime(&t, &ttm))
         return -2;
 
-    if (!OPENSSL_gmtime_diff(&day, &sec, &stm, &ttm))
+    if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
         return -2;
 
     if (day > 0)