summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-01-10 10:51:32 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-01-10 10:51:32 +0000
commit2995e5c60438da7c5cf25c25df285bfab8f4d3b5 (patch)
treed18ede85656bada98f83c8edbc0b905fc0e20b82 /lib
parentb41fd2fc4895b7e5fbbc3203dc7506d97ba6674a (diff)
Prevent a double free in EVP_MD_CTX_copy_ex()
NULL out two pointer values after memcpy() to avoid a double free. In the event that both in->pctx and in->md_data are non-NULL and the calloc() of out->md_data fails, a double free could occur. ok inoguchi jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/evp/digest.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libcrypto/evp/digest.c b/lib/libcrypto/evp/digest.c
index fd423180449..ecb52925324 100644
--- a/lib/libcrypto/evp/digest.c
+++ b/lib/libcrypto/evp/digest.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: digest.c,v 1.33 2022/01/09 15:15:25 tb Exp $ */
+/* $OpenBSD: digest.c,v 1.34 2022/01/10 10:51:31 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -281,6 +281,8 @@ EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
tmp_buf = NULL;
EVP_MD_CTX_cleanup(out);
memcpy(out, in, sizeof *out);
+ out->md_data = NULL;
+ out->pctx = NULL;
/*
* Because of the EVP_PKEY_CTX_dup() below, EVP_MD_CTX_cleanup() needs