summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-03-31 13:04:47 +0000
committertb <>2022-03-31 13:04:47 +0000
commit609f16ba617e874a45ceef4f2e8463f010e5dbe7 (patch)
tree88ae98d3fcd6c189c79beb3f91830767065ae849
parentd42bd80cba6b796dfe5030a440f5fadc50333b20 (diff)
downloadopenbsd-609f16ba617e874a45ceef4f2e8463f010e5dbe7.tar.gz
openbsd-609f16ba617e874a45ceef4f2e8463f010e5dbe7.tar.bz2
openbsd-609f16ba617e874a45ceef4f2e8463f010e5dbe7.zip
Fix leak in ASN1_TIME_adj_internal()
p is allocated by asprintf() in one of the *_from_tm() functions, so it needs to be freed as in the other error path below. CID 346194 ok jsing
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index db9382502f..5be2ff0af2 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.18 2021/08/28 08:22:48 tb Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.19 2022/03/31 13:04:47 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -259,7 +259,7 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec,
259 int allocated = 0; 259 int allocated = 0;
260 struct tm tm; 260 struct tm tm;
261 size_t len; 261 size_t len;
262 char * p; 262 char *p;
263 263
264 if (gmtime_r(&t, &tm) == NULL) 264 if (gmtime_r(&t, &tm) == NULL)
265 return (NULL); 265 return (NULL);
@@ -288,8 +288,10 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec,
288 } 288 }
289 289
290 if (s == NULL) { 290 if (s == NULL) {
291 if ((s = ASN1_TIME_new()) == NULL) 291 if ((s = ASN1_TIME_new()) == NULL) {
292 free(p);
292 return (NULL); 293 return (NULL);
294 }
293 allocated = 1; 295 allocated = 1;
294 } 296 }
295 297