Use correct date and filename.
[openssl.git] / crypto / asn1 / a_time.c
index 3a03c9e4e4863857588d6f2b862b0f456fcc7c59..159681fbcb060c6f2f95ba4ef0717979d7a2d8ce 100644 (file)
@@ -105,7 +105,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
 
        ts=OPENSSL_gmtime(&t,&data);
        if (ts == NULL)
+               {
+               ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME);
                return NULL;
+               }
        if((ts->tm_year >= 50) && (ts->tm_year < 150))
                                        return ASN1_UTCTIME_set(s, t);
        return ASN1_GENERALIZEDTIME_set(s,t);
@@ -125,6 +128,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
        {
        ASN1_GENERALIZEDTIME *ret;
        char *str;
+       int newlen;
 
        if (!ASN1_TIME_check(t)) return NULL;
 
@@ -147,12 +151,14 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
        /* grow the string */
        if (!ASN1_STRING_set(ret, NULL, t->length + 2))
                return NULL;
+       /* ASN1_STRING_set() allocated 'len + 1' bytes. */
+       newlen = t->length + 2 + 1;
        str = (char *)ret->data;
        /* Work out the century and prepend */
-       if (t->data[0] >= '5') strcpy(str, "19");
-       else strcpy(str, "20");
+       if (t->data[0] >= '5') BUF_strlcpy(str, "19", newlen);
+       else BUF_strlcpy(str, "20", newlen);
 
-       BUF_strlcat(str, (char *)t->data, t->length+3); /* Include space for a '\0' */
+       BUF_strlcat(str, (char *)t->data, newlen);
 
        return ret;
        }