summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-05-03 18:15:27 +0000
committertb <>2024-05-03 18:15:27 +0000
commit11931f26ccf226e604c3cade768b7d6a351fc7e9 (patch)
tree70ad3983d7f5d41bdfe3f1009045779ebcc9ac80
parente679c1b3b0f5cb90dcd621542a46d60836db83d5 (diff)
downloadopenbsd-11931f26ccf226e604c3cade768b7d6a351fc7e9.tar.gz
openbsd-11931f26ccf226e604c3cade768b7d6a351fc7e9.tar.bz2
openbsd-11931f26ccf226e604c3cade768b7d6a351fc7e9.zip
Simplify tm handling in ASN1_time_parse()
The CBS version asn1_time_parse_cbs() handles a NULL tm gracefully, so there is no need to avoid it by passing a pointer to a tm on the stack. ok beck
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index 9faa4ba5dc..283a5c4453 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.38 2024/04/11 06:49:19 tb Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.39 2024/05/03 18:15:27 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -293,7 +293,6 @@ asn1_time_parse_cbs(const CBS *cbs, int is_gentime, struct tm *out_tm)
293int 293int
294ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) 294ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode)
295{ 295{
296 struct tm tml, *tmp = tm ? tm : &tml;
297 int type = 0; 296 int type = 0;
298 CBS cbs; 297 CBS cbs;
299 298
@@ -306,7 +305,7 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode)
306 type = V_ASN1_UTCTIME; 305 type = V_ASN1_UTCTIME;
307 if (CBS_len(&cbs) == GENTIME_LENGTH) 306 if (CBS_len(&cbs) == GENTIME_LENGTH)
308 type = V_ASN1_GENERALIZEDTIME; 307 type = V_ASN1_GENERALIZEDTIME;
309 if (asn1_time_parse_cbs(&cbs, type == V_ASN1_GENERALIZEDTIME, tmp)) { 308 if (asn1_time_parse_cbs(&cbs, type == V_ASN1_GENERALIZEDTIME, tm)) {
310 if (mode != 0 && mode != type) 309 if (mode != 0 && mode != type)
311 return -1; 310 return -1;
312 return type; 311 return type;