diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_utctm.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_utctm.c | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c index e75f2ecbb6..d8135d0457 100644 --- a/src/lib/libcrypto/asn1/a_utctm.c +++ b/src/lib/libcrypto/asn1/a_utctm.c | |||
@@ -77,13 +77,11 @@ ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, unsigned char **pp, | |||
77 | 77 | ||
78 | ret=(ASN1_UTCTIME *)d2i_ASN1_bytes((ASN1_STRING **)a,pp,length, | 78 | ret=(ASN1_UTCTIME *)d2i_ASN1_bytes((ASN1_STRING **)a,pp,length, |
79 | V_ASN1_UTCTIME,V_ASN1_UNIVERSAL); | 79 | V_ASN1_UTCTIME,V_ASN1_UNIVERSAL); |
80 | if (ret == NULL) | 80 | if (ret == NULL) { |
81 | { | ||
82 | ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR); | 81 | ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR); |
83 | return(NULL); | 82 | return(NULL); |
84 | } | 83 | } |
85 | if (!ASN1_UTCTIME_check(ret)) | 84 | if (!ASN1_UTCTIME_check(ret)) { |
86 | { | ||
87 | ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_INVALID_TIME_FORMAT); | 85 | ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_INVALID_TIME_FORMAT); |
88 | goto err; | 86 | goto err; |
89 | } | 87 | } |
@@ -110,11 +108,12 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d) | |||
110 | o=0; | 108 | o=0; |
111 | 109 | ||
112 | if (l < 11) goto err; | 110 | if (l < 11) goto err; |
113 | for (i=0; i<6; i++) | 111 | for (i=0; i<6; i++) { |
114 | { | ||
115 | if ((i == 5) && ((a[o] == 'Z') || | 112 | if ((i == 5) && ((a[o] == 'Z') || |
116 | (a[o] == '+') || (a[o] == '-'))) | 113 | (a[o] == '+') || (a[o] == '-'))) { |
117 | { i++; break; } | 114 | i++; |
115 | break; | ||
116 | } | ||
118 | if ((a[o] < '0') || (a[o] > '9')) goto err; | 117 | if ((a[o] < '0') || (a[o] > '9')) goto err; |
119 | n= a[o]-'0'; | 118 | n= a[o]-'0'; |
120 | if (++o > l) goto err; | 119 | if (++o > l) goto err; |
@@ -127,12 +126,10 @@ int ASN1_UTCTIME_check(ASN1_UTCTIME *d) | |||
127 | } | 126 | } |
128 | if (a[o] == 'Z') | 127 | if (a[o] == 'Z') |
129 | o++; | 128 | o++; |
130 | else if ((a[o] == '+') || (a[o] == '-')) | 129 | else if ((a[o] == '+') || (a[o] == '-')) { |
131 | { | ||
132 | o++; | 130 | o++; |
133 | if (o+4 > l) goto err; | 131 | if (o+4 > l) goto err; |
134 | for (i=6; i<8; i++) | 132 | for (i=6; i<8; i++) { |
135 | { | ||
136 | if ((a[o] < '0') || (a[o] > '9')) goto err; | 133 | if ((a[o] < '0') || (a[o] > '9')) goto err; |
137 | n= a[o]-'0'; | 134 | n= a[o]-'0'; |
138 | o++; | 135 | o++; |
@@ -154,18 +151,15 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) | |||
154 | t.type=V_ASN1_UTCTIME; | 151 | t.type=V_ASN1_UTCTIME; |
155 | t.length=strlen(str); | 152 | t.length=strlen(str); |
156 | t.data=(unsigned char *)str; | 153 | t.data=(unsigned char *)str; |
157 | if (ASN1_UTCTIME_check(&t)) | 154 | if (ASN1_UTCTIME_check(&t)) { |
158 | { | 155 | if (s != NULL) { |
159 | if (s != NULL) | ||
160 | { | ||
161 | if (!ASN1_STRING_set((ASN1_STRING *)s, | 156 | if (!ASN1_STRING_set((ASN1_STRING *)s, |
162 | (unsigned char *)str,t.length)) | 157 | (unsigned char *)str,t.length)) |
163 | return 0; | 158 | return 0; |
164 | s->type = V_ASN1_UTCTIME; | 159 | s->type = V_ASN1_UTCTIME; |
165 | } | 160 | } |
166 | return(1); | 161 | return(1); |
167 | } | 162 | } else |
168 | else | ||
169 | return(0); | 163 | return(0); |
170 | } | 164 | } |
171 | 165 | ||
@@ -191,8 +185,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, | |||
191 | if (ts == NULL) | 185 | if (ts == NULL) |
192 | return(NULL); | 186 | return(NULL); |
193 | 187 | ||
194 | if (offset_day || offset_sec) | 188 | if (offset_day || offset_sec) { |
195 | { | ||
196 | if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) | 189 | if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) |
197 | return NULL; | 190 | return NULL; |
198 | } | 191 | } |
@@ -201,11 +194,9 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, | |||
201 | return NULL; | 194 | return NULL; |
202 | 195 | ||
203 | p=(char *)s->data; | 196 | p=(char *)s->data; |
204 | if ((p == NULL) || ((size_t)s->length < len)) | 197 | if ((p == NULL) || ((size_t)s->length < len)) { |
205 | { | ||
206 | p=malloc(len); | 198 | p=malloc(len); |
207 | if (p == NULL) | 199 | if (p == NULL) { |
208 | { | ||
209 | ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE); | 200 | ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE); |
210 | return(NULL); | 201 | return(NULL); |
211 | } | 202 | } |
@@ -233,8 +224,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) | |||
233 | 224 | ||
234 | if (s->data[12] == 'Z') | 225 | if (s->data[12] == 'Z') |
235 | offset=0; | 226 | offset=0; |
236 | else | 227 | else { |
237 | { | ||
238 | offset = g2(s->data+13)*60+g2(s->data+15); | 228 | offset = g2(s->data+13)*60+g2(s->data+15); |
239 | if (s->data[12] == '-') | 229 | if (s->data[12] == '-') |
240 | offset = -offset; | 230 | offset = -offset; |
@@ -280,8 +270,7 @@ time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s) | |||
280 | tm.tm_sec=g2(s->data+10); | 270 | tm.tm_sec=g2(s->data+10); |
281 | if(s->data[12] == 'Z') | 271 | if(s->data[12] == 'Z') |
282 | offset=0; | 272 | offset=0; |
283 | else | 273 | else { |
284 | { | ||
285 | offset=g2(s->data+13)*60+g2(s->data+15); | 274 | offset=g2(s->data+13)*60+g2(s->data+15); |
286 | if(s->data[12] == '-') | 275 | if(s->data[12] == '-') |
287 | offset= -offset; | 276 | offset= -offset; |