diff options
author | beck <> | 2020-09-14 08:06:09 +0000 |
---|---|---|
committer | beck <> | 2020-09-14 08:06:09 +0000 |
commit | 768b16b50556fec6a7dc1b87ea26cd72846a4e44 (patch) | |
tree | 7817d771ea189cb5e5d9b62c8caa01a3d5b1142e | |
parent | a6cea568b127c03f3420f698c0647e80bde07008 (diff) | |
download | openbsd-768b16b50556fec6a7dc1b87ea26cd72846a4e44.tar.gz openbsd-768b16b50556fec6a7dc1b87ea26cd72846a4e44.tar.bz2 openbsd-768b16b50556fec6a7dc1b87ea26cd72846a4e44.zip |
Correctly fix double free introduced on review.
the roots for a ctx are only freed in the free function, not in the
clear function, so that a ctx can be re-used with the same roots.
ok tb@
-rw-r--r-- | src/lib/libcrypto/x509/x509_verify.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_verify.c b/src/lib/libcrypto/x509/x509_verify.c index 5f5070c122..aeab03ffc2 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.1 2020/09/13 15:06:17 beck Exp $ */ | 1 | /* $OpenBSD: x509_verify.c,v 1.2 2020/09/14 08:06:09 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -153,7 +153,6 @@ x509_verify_ctx_clear(struct x509_verify_ctx *ctx) | |||
153 | { | 153 | { |
154 | x509_verify_ctx_reset(ctx); | 154 | x509_verify_ctx_reset(ctx); |
155 | sk_X509_pop_free(ctx->intermediates, X509_free); | 155 | sk_X509_pop_free(ctx->intermediates, X509_free); |
156 | sk_X509_pop_free(ctx->roots, X509_free); | ||
157 | free(ctx->chains); | 156 | free(ctx->chains); |
158 | memset(ctx, 0, sizeof(*ctx)); | 157 | memset(ctx, 0, sizeof(*ctx)); |
159 | } | 158 | } |
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index f076a1dc5c..a66ef76e6b 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_vfy.c,v 1.76 2020/09/14 07:46:01 beck Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.77 2020/09/14 08:06:09 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -682,6 +682,7 @@ X509_verify_cert(X509_STORE_CTX *ctx) | |||
682 | chain_count = x509_verify(vctx, NULL, NULL); | 682 | chain_count = x509_verify(vctx, NULL, NULL); |
683 | } | 683 | } |
684 | 684 | ||
685 | sk_X509_pop_free(roots, X509_free); | ||
685 | x509_verify_ctx_free(vctx); | 686 | x509_verify_ctx_free(vctx); |
686 | 687 | ||
687 | /* if we succeed we have a chain in ctx->chain */ | 688 | /* if we succeed we have a chain in ctx->chain */ |