summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-05-03 18:33:27 +0000
committertb <>2024-05-03 18:33:27 +0000
commit39176fb1389c5daf8cc1b84bbf27eef3936a1ba4 (patch)
tree7f9b7370d03ebc8e67cd08c503326dad5f95d6a6
parent603c25396734cafcf5052772d80d74998ed629a3 (diff)
downloadopenbsd-39176fb1389c5daf8cc1b84bbf27eef3936a1ba4.tar.gz
openbsd-39176fb1389c5daf8cc1b84bbf27eef3936a1ba4.tar.bz2
openbsd-39176fb1389c5daf8cc1b84bbf27eef3936a1ba4.zip
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
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index c13b9b5064..a1f329be96 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.41 2024/05/03 18:29:43 tb Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.42 2024/05/03 18:33: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 *
@@ -88,9 +88,6 @@ tm_to_gentime(struct tm *tm, ASN1_TIME *atime)
88 return 0; 88 return 0;
89 } 89 }
90 90
91 if (atime == NULL)
92 return 1;
93
94 if (asprintf(&time_str, "%04u%02u%02u%02u%02u%02uZ", tm->tm_year + 1900, 91 if (asprintf(&time_str, "%04u%02u%02u%02u%02u%02uZ", tm->tm_year + 1900,
95 tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, 92 tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
96 tm->tm_sec) == -1) { 93 tm->tm_sec) == -1) {
@@ -117,9 +114,6 @@ tm_to_utctime(struct tm *tm, ASN1_TIME *atime)
117 return 0; 114 return 0;
118 } 115 }
119 116
120 if (atime == NULL)
121 return 1;
122
123 if (asprintf(&time_str, "%02u%02u%02u%02u%02u%02uZ", 117 if (asprintf(&time_str, "%02u%02u%02u%02u%02u%02uZ",
124 tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, 118 tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
125 tm->tm_hour, tm->tm_min, tm->tm_sec) == -1) { 119 tm->tm_hour, tm->tm_min, tm->tm_sec) == -1) {