Revision aa3b4b4d deps/openssl/openssl/crypto/asn1/a_utctm.c

View differences:

deps/openssl/openssl/crypto/asn1/a_utctm.c
196 196
	struct tm *ts;
197 197
	struct tm data;
198 198
	size_t len = 20;
199
	int free_s = 0;
199 200

  
200 201
	if (s == NULL)
202
		{
203
		free_s = 1;
201 204
		s=M_ASN1_UTCTIME_new();
205
		}
202 206
	if (s == NULL)
203
		return(NULL);
207
		goto err;
208

  
204 209

  
205 210
	ts=OPENSSL_gmtime(&t, &data);
206 211
	if (ts == NULL)
207
		return(NULL);
212
		goto err;
208 213

  
209 214
	if (offset_day || offset_sec)
210 215
		{ 
211 216
		if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
212
			return NULL;
217
			goto err;
213 218
		}
214 219

  
215 220
	if((ts->tm_year < 50) || (ts->tm_year >= 150))
216
		return NULL;
221
		goto err;
217 222

  
218 223
	p=(char *)s->data;
219 224
	if ((p == NULL) || ((size_t)s->length < len))
......
222 227
		if (p == NULL)
223 228
			{
224 229
			ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
225
			return(NULL);
230
			goto err;
226 231
			}
227 232
		if (s->data != NULL)
228 233
			OPENSSL_free(s->data);
......
237 242
	ebcdic2ascii(s->data, s->data, s->length);
238 243
#endif
239 244
	return(s);
245
	err:
246
	if (free_s && s)
247
		M_ASN1_UTCTIME_free(s);
248
	return NULL;
240 249
	}
241 250

  
242 251

  
......
261 270
	t -= offset*60; /* FIXME: may overflow in extreme cases */
262 271

  
263 272
	tm = OPENSSL_gmtime(&t, &data);
273
	/* NB: -1, 0, 1 already valid return values so use -2 to
274
	 * indicate error.
275
	 */
276
	if (tm == NULL)
277
		return -2;
264 278
	
265 279
#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
266 280
	year = g2(s->data);

Also available in: Unified diff