From 4b23cd33e69145f0c5307d8011cad8d778edac59 Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 3 May 2024 18:15:27 +0000 Subject: [PATCH] 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 --- lib/libcrypto/asn1/a_time_tm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/libcrypto/asn1/a_time_tm.c b/lib/libcrypto/asn1/a_time_tm.c index 9faa4ba5dc6..283a5c44539 100644 --- a/lib/libcrypto/asn1/a_time_tm.c +++ b/lib/libcrypto/asn1/a_time_tm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time_tm.c,v 1.38 2024/04/11 06:49:19 tb Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.39 2024/05/03 18:15:27 tb Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -293,7 +293,6 @@ asn1_time_parse_cbs(const CBS *cbs, int is_gentime, struct tm *out_tm) int ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) { - struct tm tml, *tmp = tm ? tm : &tml; int type = 0; CBS cbs; @@ -306,7 +305,7 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) type = V_ASN1_UTCTIME; if (CBS_len(&cbs) == GENTIME_LENGTH) type = V_ASN1_GENERALIZEDTIME; - if (asn1_time_parse_cbs(&cbs, type == V_ASN1_GENERALIZEDTIME, tmp)) { + if (asn1_time_parse_cbs(&cbs, type == V_ASN1_GENERALIZEDTIME, tm)) { if (mode != 0 && mode != type) return -1; return type; -- 2.20.1