diff options
Diffstat (limited to 'lib/libcrypto/asn1/a_gentm.c')
-rw-r--r-- | lib/libcrypto/asn1/a_gentm.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/libcrypto/asn1/a_gentm.c b/lib/libcrypto/asn1/a_gentm.c index f331bff3202..7f8bc2fef72 100644 --- a/lib/libcrypto/asn1/a_gentm.c +++ b/lib/libcrypto/asn1/a_gentm.c @@ -208,20 +208,15 @@ ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t) return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0); } -ASN1_GENERALIZEDTIME * -ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, - long offset_sec) +static ASN1_GENERALIZEDTIME * +ASN1_GENERALIZEDTIME_adj_internal(ASN1_GENERALIZEDTIME *s, time_t t, + int offset_day, long offset_sec) { char *p; struct tm *ts; struct tm data; size_t len = 20; - if (s == NULL) - s = M_ASN1_GENERALIZEDTIME_new(); - if (s == NULL) - return (NULL); - ts = gmtime_r(&t, &data); if (ts == NULL) return (NULL); @@ -250,3 +245,24 @@ ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, s->type = V_ASN1_GENERALIZEDTIME; return (s); } + +ASN1_GENERALIZEDTIME * +ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, + long offset_sec) +{ + ASN1_GENERALIZEDTIME *tmp = NULL, *ret; + + if (s == NULL) { + tmp = M_ASN1_GENERALIZEDTIME_new(); + if (tmp == NULL) + return NULL; + s = tmp; + } + + ret = ASN1_GENERALIZEDTIME_adj_internal(s, t, offset_day, offset_sec); + if (ret == NULL && tmp != NULL) + M_ASN1_GENERALIZEDTIME_free(tmp); + + return ret; + +} |