diff options
author | tb <> | 2020-11-18 17:54:46 +0000 |
---|---|---|
committer | tb <> | 2020-11-18 17:54:46 +0000 |
commit | 55e64e549e2ba5234b327630d22faf48d66de9ee (patch) | |
tree | d7ab734b9207f1fc27a3037da6009a48c70fd641 /src/lib | |
parent | c67f3c9390fc29f3f4e97751c76c023f647bc9ec (diff) | |
download | openbsd-55e64e549e2ba5234b327630d22faf48d66de9ee.tar.gz openbsd-55e64e549e2ba5234b327630d22faf48d66de9ee.tar.bz2 openbsd-55e64e549e2ba5234b327630d22faf48d66de9ee.zip |
Plug leak in x509_verify_chain_dup()
x509_verify_chain_new() allocates a few members of a certificate chain:
an empty stack of certificates, a list of errors encountered while
validating the chain, and a list of name constraints. The function to
copy a chain would allocate a new chain using x509_verify_chain_new()
and then clobber its members by copies of the old chain. Fix this by
replacing x509_verify_chain_new() with calloc().
Found by review while investigating the report by Hanno Zysik who
found the same leak using valgrind. This is a cleaner version of
my initial fix from jsing.
ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509_verify.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/x509/x509_verify.c b/src/lib/libcrypto/x509/x509_verify.c index 76cc70a204..59a8a1e5b6 100644 --- a/src/lib/libcrypto/x509/x509_verify.c +++ b/src/lib/libcrypto/x509/x509_verify.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_verify.c,v 1.23 2020/11/18 17:13:55 tb Exp $ */ | 1 | /* $OpenBSD: x509_verify.c,v 1.24 2020/11/18 17:54:46 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -86,7 +86,7 @@ x509_verify_chain_dup(struct x509_verify_chain *chain) | |||
86 | { | 86 | { |
87 | struct x509_verify_chain *new_chain; | 87 | struct x509_verify_chain *new_chain; |
88 | 88 | ||
89 | if ((new_chain = x509_verify_chain_new()) == NULL) | 89 | if ((new_chain = calloc(1, sizeof(*chain))) == NULL) |
90 | goto err; | 90 | goto err; |
91 | if ((new_chain->certs = X509_chain_up_ref(chain->certs)) == NULL) | 91 | if ((new_chain->certs = X509_chain_up_ref(chain->certs)) == NULL) |
92 | goto err; | 92 | goto err; |