summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index c8eabec08f..16b9df2584 100644
--- a/src/lib/libcrypto/asn1/a_time_tm.c
+++ b/src/lib/libcrypto/asn1/a_time_tm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_time_tm.c,v 1.34 2024/04/08 19:57:40 beck Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.35 2024/04/09 13:56:00 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -344,21 +344,32 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode)
344static int 344static int
345ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) 345ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode)
346{ 346{
347 ASN1_TIME *atime = s;
347 struct tm tm; 348 struct tm tm;
348 int type; 349 int type;
350 int ret = 0;
349 351
350 if ((type = ASN1_time_parse(str, strlen(str), &tm, mode)) == -1) 352 if ((type = ASN1_time_parse(str, strlen(str), &tm, mode)) == -1)
351 return (0); 353 return (0);
352 switch(mode) { 354 switch (mode) {
353 case V_ASN1_UTCTIME: 355 case V_ASN1_UTCTIME:
354 return (type == mode && tm_to_utctime(&tm, s) != NULL); 356 ret = (type == mode && (atime = tm_to_utctime(&tm, s)) != NULL);
357 break;
355 case V_ASN1_GENERALIZEDTIME: 358 case V_ASN1_GENERALIZEDTIME:
356 return (type == mode && tm_to_gentime(&tm, s) != NULL); 359 ret = (type == mode && (atime = tm_to_gentime(&tm, s)) != NULL);
360 break;
357 case RFC5280: 361 case RFC5280:
358 return (tm_to_rfc5280_time(&tm, s) != NULL); 362 ret = ((atime = tm_to_rfc5280_time(&tm, s)) != NULL);
363 break;
359 default: 364 default:
360 return (0); 365 ret = 0;
366 break;
361 } 367 }
368
369 if (atime != s)
370 ASN1_TIME_free(atime);
371
372 return ret;
362} 373}
363 374
364static ASN1_TIME * 375static ASN1_TIME *