Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: openssl/crypto/asn1/a_utctm.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/crypto/asn1/a_type.c ('k') | openssl/crypto/asn1/a_verify.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/asn1/a_utctm.c */ 1 /* crypto/asn1/a_utctm.c */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 err: 107 err:
108 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 108 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
109 M_ASN1_UTCTIME_free(ret); 109 M_ASN1_UTCTIME_free(ret);
110 return(NULL); 110 return(NULL);
111 } 111 }
112 112
113 #endif 113 #endif
114 114
115 int ASN1_UTCTIME_check(ASN1_UTCTIME *d) 115 int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
116 { 116 {
117 » static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; 117 » static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
118 » static int max[8]={99,12,31,23,59,59,12,59}; 118 » static const 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
122 if (d->type != V_ASN1_UTCTIME) return(0); 122 if (d->type != V_ASN1_UTCTIME) return(0);
123 l=d->length; 123 l=d->length;
124 a=(char *)d->data; 124 a=(char *)d->data;
125 o=0; 125 o=0;
126 126
127 if (l < 11) goto err; 127 if (l < 11) goto err;
128 for (i=0; i<6; i++) 128 for (i=0; i<6; i++)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 s->type = V_ASN1_UTCTIME; 179 s->type = V_ASN1_UTCTIME;
180 } 180 }
181 return(1); 181 return(1);
182 } 182 }
183 else 183 else
184 return(0); 184 return(0);
185 } 185 }
186 186
187 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) 187 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
188 { 188 {
189 return ASN1_UTCTIME_adj(s, t, 0, 0);
190 }
191
192 ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
193 int offset_day, long offset_sec)
194 {
189 char *p; 195 char *p;
190 struct tm *ts; 196 struct tm *ts;
191 struct tm data; 197 struct tm data;
192 size_t len = 20; 198 size_t len = 20;
193 199
194 if (s == NULL) 200 if (s == NULL)
195 s=M_ASN1_UTCTIME_new(); 201 s=M_ASN1_UTCTIME_new();
196 if (s == NULL) 202 if (s == NULL)
197 return(NULL); 203 return(NULL);
198 204
199 ts=OPENSSL_gmtime(&t, &data); 205 ts=OPENSSL_gmtime(&t, &data);
200 if (ts == NULL) 206 if (ts == NULL)
201 return(NULL); 207 return(NULL);
202 208
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
203 p=(char *)s->data; 218 p=(char *)s->data;
204 if ((p == NULL) || ((size_t)s->length < len)) 219 if ((p == NULL) || ((size_t)s->length < len))
205 { 220 {
206 p=OPENSSL_malloc(len); 221 p=OPENSSL_malloc(len);
207 if (p == NULL) 222 if (p == NULL)
208 { 223 {
209 » » » ASN1err(ASN1_F_ASN1_UTCTIME_SET,ERR_R_MALLOC_FAILURE); 224 » » » ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
210 return(NULL); 225 return(NULL);
211 } 226 }
212 if (s->data != NULL) 227 if (s->data != NULL)
213 OPENSSL_free(s->data); 228 OPENSSL_free(s->data);
214 s->data=(unsigned char *)p; 229 s->data=(unsigned char *)p;
215 } 230 }
216 231
217 BIO_snprintf(p,len,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100, 232 BIO_snprintf(p,len,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100,
218 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec) ; 233 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec) ;
219 s->length=strlen(p); 234 s->length=strlen(p);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return mktime(&tm)-offset*60; /* FIXME: mktime assumes the current timez one 309 return mktime(&tm)-offset*60; /* FIXME: mktime assumes the current timez one
295 * instead of UTC, and unless we rewrite O penSSL 310 * instead of UTC, and unless we rewrite O penSSL
296 * in Lisp we cannot locally change the ti mezone 311 * in Lisp we cannot locally change the ti mezone
297 * without possibly interfering with other parts 312 * without possibly interfering with other parts
298 * of the program. timegm, which uses UTC, is 313 * of the program. timegm, which uses UTC, is
299 * non-standard. 314 * non-standard.
300 * Also time_t is inappropriate for genera l 315 * Also time_t is inappropriate for genera l
301 * UTC times because it may a 32 bit type. */ 316 * UTC times because it may a 32 bit type. */
302 } 317 }
303 #endif 318 #endif
OLDNEW
« no previous file with comments | « openssl/crypto/asn1/a_type.c ('k') | openssl/crypto/asn1/a_verify.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698