From: tb Date: Fri, 3 May 2024 18:33:27 +0000 (+0000) Subject: Remove disgusting NULL checks in tm_to_{gentime,utctime}() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c604ab84837e7f949d28ecd1ff96b40c36777c45;p=openbsd Remove disgusting NULL checks in tm_to_{gentime,utctime}() The only caller that could potentially call these with NULL has been fixed. This way an ugly hack that was needed to plug a memory leak can go away and the functions again behave as intended without OpenSSL-style workarounds. ok beck --- diff --git a/lib/libcrypto/asn1/a_time_tm.c b/lib/libcrypto/asn1/a_time_tm.c index c13b9b50646..a1f329be967 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.41 2024/05/03 18:29:43 tb Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.42 2024/05/03 18:33:27 tb Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -88,9 +88,6 @@ tm_to_gentime(struct tm *tm, ASN1_TIME *atime) return 0; } - if (atime == NULL) - return 1; - if (asprintf(&time_str, "%04u%02u%02u%02u%02u%02uZ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec) == -1) { @@ -117,9 +114,6 @@ tm_to_utctime(struct tm *tm, ASN1_TIME *atime) return 0; } - if (atime == NULL) - return 1; - if (asprintf(&time_str, "%02u%02u%02u%02u%02u%02uZ", tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec) == -1) {