Skip to content

Commit a87c395

Browse files
author
tb
committed
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
1 parent 3e9c21a commit a87c395

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lib/libcrypto/asn1/a_time_tm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 $ */
22
/*
33
* Copyright (c) 2015 Bob Beck <beck@openbsd.org>
44
*
@@ -259,7 +259,7 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec,
259259
int allocated = 0;
260260
struct tm tm;
261261
size_t len;
262-
char * p;
262+
char *p;
263263

264264
if (gmtime_r(&t, &tm) == NULL)
265265
return (NULL);
@@ -288,8 +288,10 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec,
288288
}
289289

290290
if (s == NULL) {
291-
if ((s = ASN1_TIME_new()) == NULL)
291+
if ((s = ASN1_TIME_new()) == NULL) {
292+
free(p);
292293
return (NULL);
294+
}
293295
allocated = 1;
294296
}
295297

0 commit comments

Comments
 (0)