diff options
| author | tb <> | 2022-03-31 13:04:47 +0000 |
|---|---|---|
| committer | tb <> | 2022-03-31 13:04:47 +0000 |
| commit | 31dad1243d69de787b0589750cc4b78379c43734 (patch) | |
| tree | 88ae98d3fcd6c189c79beb3f91830767065ae849 /src | |
| parent | 91087446015ebb4341a9f7c6accff0e586a0ba5d (diff) | |
| download | openbsd-31dad1243d69de787b0589750cc4b78379c43734.tar.gz openbsd-31dad1243d69de787b0589750cc4b78379c43734.tar.bz2 openbsd-31dad1243d69de787b0589750cc4b78379c43734.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
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_time_tm.c | 8 |
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 | ||
