diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-03-31 13:04:48 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-03-31 13:04:48 +0000 |
commit | fae1e264bb650b32dea8e9ba421d6ccdc47910f8 (patch) | |
tree | f4d9c201e95a72ad31abe90900cfc09bb3b82ac1 /lib | |
parent | 369f187aff924ed2f8aedb2dfe146089860c3752 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/asn1/a_time_tm.c | 8 |
1 files changed, 5 insertions, 3 deletions
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 <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; } |