From 609f16ba617e874a45ceef4f2e8463f010e5dbe7 Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 31 Mar 2022 13:04:47 +0000 Subject: 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 --- src/lib/libcrypto/asn1/a_time_tm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib') 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 @@ -/* $OpenBSD: a_time_tm.c,v 1.18 2021/08/28 08:22:48 tb Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.19 2022/03/31 13:04:47 tb Exp $ */ /* * Copyright (c) 2015 Bob Beck <beck@openbsd.org> * @@ -259,7 +259,7 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, int allocated = 0; struct tm tm; size_t len; - char * p; + char *p; if (gmtime_r(&t, &tm) == NULL) return (NULL); @@ -288,8 +288,10 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, } if (s == NULL) { - if ((s = ASN1_TIME_new()) == NULL) + if ((s = ASN1_TIME_new()) == NULL) { + free(p); return (NULL); + } allocated = 1; } -- cgit v1.2.3-55-g6feb