From: tb Date: Thu, 31 Mar 2022 13:04:47 +0000 (+0000) Subject: Fix leak in ASN1_TIME_adj_internal() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=51e08eda6f4b948b69e98fe4e19bd034d3340a80;p=openbsd 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 --- diff --git a/lib/libcrypto/asn1/a_time_tm.c b/lib/libcrypto/asn1/a_time_tm.c index db9382502fd..5be2ff0af2c 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.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 * @@ -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; }