summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_utctm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_utctm.c')
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index 072e236592..d31c028193 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -114,8 +114,8 @@ err:
114 114
115int ASN1_UTCTIME_check(ASN1_UTCTIME *d) 115int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
116 { 116 {
117 static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; 117 static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
118 static const int max[8]={99,12,31,23,59,59,12,59}; 118 static int max[8]={99,12,31,23,59,59,12,59};
119 char *a; 119 char *a;
120 int n,i,l,o; 120 int n,i,l,o;
121 121
@@ -186,12 +186,6 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
186 186
187ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) 187ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
188 { 188 {
189 return ASN1_UTCTIME_adj(s, t, 0, 0);
190 }
191
192ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
193 int offset_day, long offset_sec)
194 {
195 char *p; 189 char *p;
196 struct tm *ts; 190 struct tm *ts;
197 struct tm data; 191 struct tm data;
@@ -206,22 +200,13 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
206 if (ts == NULL) 200 if (ts == NULL)
207 return(NULL); 201 return(NULL);
208 202
209 if (offset_day || offset_sec)
210 {
211 if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
212 return NULL;
213 }
214
215 if((ts->tm_year < 50) || (ts->tm_year >= 150))
216 return NULL;
217
218 p=(char *)s->data; 203 p=(char *)s->data;
219 if ((p == NULL) || ((size_t)s->length < len)) 204 if ((p == NULL) || ((size_t)s->length < len))
220 { 205 {
221 p=OPENSSL_malloc(len); 206 p=OPENSSL_malloc(len);
222 if (p == NULL) 207 if (p == NULL)
223 { 208 {
224 ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE); 209 ASN1err(ASN1_F_ASN1_UTCTIME_SET,ERR_R_MALLOC_FAILURE);
225 return(NULL); 210 return(NULL);
226 } 211 }
227 if (s->data != NULL) 212 if (s->data != NULL)