summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_time.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_time.c')
-rw-r--r--src/lib/libcrypto/asn1/a_time.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index 25a1805640..a6c7c8e736 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_time.c,v 1.25 2015/09/30 18:04:02 jsing Exp $ */ 1/* $OpenBSD: a_time.c,v 1.26 2015/10/02 15:04:45 beck Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -68,7 +68,7 @@
68#include <openssl/err.h> 68#include <openssl/err.h>
69 69
70#include "o_time.h" 70#include "o_time.h"
71 71#include "asn1_locl.h"
72 72
73const ASN1_ITEM ASN1_TIME_it = { 73const ASN1_ITEM ASN1_TIME_it = {
74 .itype = ASN1_ITYPE_MSTRING, 74 .itype = ASN1_ITYPE_MSTRING,
@@ -135,11 +135,9 @@ ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec)
135int 135int
136ASN1_TIME_check(ASN1_TIME *t) 136ASN1_TIME_check(ASN1_TIME *t)
137{ 137{
138 if (t->type == V_ASN1_GENERALIZEDTIME) 138 if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME)
139 return ASN1_GENERALIZEDTIME_check(t); 139 return 0;
140 else if (t->type == V_ASN1_UTCTIME) 140 return (t->type == asn1_time_parse(t->data, t->length, NULL, t->type));
141 return ASN1_UTCTIME_check(t);
142 return 0;
143} 141}
144 142
145/* Convert an ASN1_TIME structure to GeneralizedTime */ 143/* Convert an ASN1_TIME structure to GeneralizedTime */
@@ -210,13 +208,12 @@ ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
210 t.data = (unsigned char *)str; 208 t.data = (unsigned char *)str;
211 t.flags = 0; 209 t.flags = 0;
212 210
213 t.type = V_ASN1_UTCTIME; 211 t.type = asn1_time_parse(t.data, t.length, NULL, V_ASN1_UTCTIME);
214 212 if (t.type == -1)
215 if (!ASN1_TIME_check(&t)) { 213 t.type = asn1_time_parse(t.data, t.length, NULL,
216 t.type = V_ASN1_GENERALIZEDTIME; 214 V_ASN1_GENERALIZEDTIME);
217 if (!ASN1_TIME_check(&t)) 215 if (t.type == -1)
218 return 0; 216 return 0;
219 }
220 217
221 if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t)) 218 if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
222 return 0; 219 return 0;