diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_gentm.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_gentm.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c index def79062a5..c79c6f538c 100644 --- a/src/lib/libcrypto/asn1/a_gentm.c +++ b/src/lib/libcrypto/asn1/a_gentm.c | |||
| @@ -117,8 +117,8 @@ err: | |||
| 117 | 117 | ||
| 118 | int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) | 118 | int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) |
| 119 | { | 119 | { |
| 120 | static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; | 120 | static const int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; |
| 121 | static int max[9]={99, 99,12,31,23,59,59,12,59}; | 121 | static const int max[9]={99, 99,12,31,23,59,59,12,59}; |
| 122 | char *a; | 122 | char *a; |
| 123 | int n,i,l,o; | 123 | int n,i,l,o; |
| 124 | 124 | ||
| @@ -176,6 +176,11 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) | |||
| 176 | o++; | 176 | o++; |
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| 179 | else | ||
| 180 | { | ||
| 181 | /* Missing time zone information. */ | ||
| 182 | goto err; | ||
| 183 | } | ||
| 179 | return(o == l); | 184 | return(o == l); |
| 180 | err: | 185 | err: |
| 181 | return(0); | 186 | return(0); |
| @@ -206,6 +211,12 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) | |||
| 206 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, | 211 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, |
| 207 | time_t t) | 212 | time_t t) |
| 208 | { | 213 | { |
| 214 | return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0); | ||
| 215 | } | ||
| 216 | |||
| 217 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, | ||
| 218 | time_t t, int offset_day, long offset_sec) | ||
| 219 | { | ||
| 209 | char *p; | 220 | char *p; |
| 210 | struct tm *ts; | 221 | struct tm *ts; |
| 211 | struct tm data; | 222 | struct tm data; |
| @@ -220,13 +231,19 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, | |||
| 220 | if (ts == NULL) | 231 | if (ts == NULL) |
| 221 | return(NULL); | 232 | return(NULL); |
| 222 | 233 | ||
| 234 | if (offset_day || offset_sec) | ||
| 235 | { | ||
| 236 | if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) | ||
| 237 | return NULL; | ||
| 238 | } | ||
| 239 | |||
| 223 | p=(char *)s->data; | 240 | p=(char *)s->data; |
| 224 | if ((p == NULL) || ((size_t)s->length < len)) | 241 | if ((p == NULL) || ((size_t)s->length < len)) |
| 225 | { | 242 | { |
| 226 | p=OPENSSL_malloc(len); | 243 | p=OPENSSL_malloc(len); |
| 227 | if (p == NULL) | 244 | if (p == NULL) |
| 228 | { | 245 | { |
| 229 | ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_SET, | 246 | ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, |
| 230 | ERR_R_MALLOC_FAILURE); | 247 | ERR_R_MALLOC_FAILURE); |
| 231 | return(NULL); | 248 | return(NULL); |
| 232 | } | 249 | } |
