diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/asn1/a_gentm.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/asn1/a_gentm.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_gentm.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c index 314479a03d..cd09f68b38 100644 --- a/src/lib/libcrypto/asn1/a_gentm.c +++ b/src/lib/libcrypto/asn1/a_gentm.c | |||
@@ -61,13 +61,10 @@ | |||
61 | #include <stdio.h> | 61 | #include <stdio.h> |
62 | #include <time.h> | 62 | #include <time.h> |
63 | #include "cryptlib.h" | 63 | #include "cryptlib.h" |
64 | #include "o_time.h" | ||
64 | #include <openssl/asn1.h> | 65 | #include <openssl/asn1.h> |
65 | 66 | ||
66 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void) | 67 | #if 0 |
67 | { return M_ASN1_GENERALIZEDTIME_new(); } | ||
68 | |||
69 | void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *x) | ||
70 | { M_ASN1_GENERALIZEDTIME_free(x); } | ||
71 | 68 | ||
72 | int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) | 69 | int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) |
73 | { | 70 | { |
@@ -116,6 +113,8 @@ err: | |||
116 | return(NULL); | 113 | return(NULL); |
117 | } | 114 | } |
118 | 115 | ||
116 | #endif | ||
117 | |||
119 | int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) | 118 | int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) |
120 | { | 119 | { |
121 | static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; | 120 | static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; |
@@ -147,6 +146,19 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) | |||
147 | 146 | ||
148 | if ((n < min[i]) || (n > max[i])) goto err; | 147 | if ((n < min[i]) || (n > max[i])) goto err; |
149 | } | 148 | } |
149 | /* Optional fractional seconds: decimal point followed by one | ||
150 | * or more digits. | ||
151 | */ | ||
152 | if (a[o] == '.') | ||
153 | { | ||
154 | if (++o > l) goto err; | ||
155 | i = o; | ||
156 | while ((a[o] >= '0') && (a[o] <= '9') && (o <= l)) | ||
157 | o++; | ||
158 | /* Must have at least one digit after decimal point */ | ||
159 | if (i == o) goto err; | ||
160 | } | ||
161 | |||
150 | if (a[o] == 'Z') | 162 | if (a[o] == 'Z') |
151 | o++; | 163 | o++; |
152 | else if ((a[o] == '+') || (a[o] == '-')) | 164 | else if ((a[o] == '+') || (a[o] == '-')) |
@@ -182,6 +194,7 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str) | |||
182 | { | 194 | { |
183 | ASN1_STRING_set((ASN1_STRING *)s, | 195 | ASN1_STRING_set((ASN1_STRING *)s, |
184 | (unsigned char *)str,t.length); | 196 | (unsigned char *)str,t.length); |
197 | s->type=V_ASN1_GENERALIZEDTIME; | ||
185 | } | 198 | } |
186 | return(1); | 199 | return(1); |
187 | } | 200 | } |
@@ -194,21 +207,17 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, | |||
194 | { | 207 | { |
195 | char *p; | 208 | char *p; |
196 | struct tm *ts; | 209 | struct tm *ts; |
197 | #if defined(THREADS) && !defined(WIN32) | ||
198 | struct tm data; | 210 | struct tm data; |
199 | #endif | ||
200 | 211 | ||
201 | if (s == NULL) | 212 | if (s == NULL) |
202 | s=M_ASN1_GENERALIZEDTIME_new(); | 213 | s=M_ASN1_GENERALIZEDTIME_new(); |
203 | if (s == NULL) | 214 | if (s == NULL) |
204 | return(NULL); | 215 | return(NULL); |
205 | 216 | ||
206 | #if defined(THREADS) && !defined(WIN32) | 217 | ts=OPENSSL_gmtime(&t, &data); |
207 | gmtime_r(&t,&data); /* should return &data, but doesn't on some systems, so we don't even look at the return value */ | 218 | if (ts == NULL) |
208 | ts=&data; | 219 | return(NULL); |
209 | #else | 220 | |
210 | ts=gmtime(&t); | ||
211 | #endif | ||
212 | p=(char *)s->data; | 221 | p=(char *)s->data; |
213 | if ((p == NULL) || (s->length < 16)) | 222 | if ((p == NULL) || (s->length < 16)) |
214 | { | 223 | { |