diff options
author | tb <> | 2022-01-10 10:51:31 +0000 |
---|---|---|
committer | tb <> | 2022-01-10 10:51:31 +0000 |
commit | 0af4f789497e3f3ba6818138f64585c080464044 (patch) | |
tree | e06f01c1949048520df738b0696be8e54d046570 | |
parent | e6455ffc48d2de0b70e7d5f20d35cd4e78d121e7 (diff) | |
download | openbsd-0af4f789497e3f3ba6818138f64585c080464044.tar.gz openbsd-0af4f789497e3f3ba6818138f64585c080464044.tar.bz2 openbsd-0af4f789497e3f3ba6818138f64585c080464044.zip |
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
-rw-r--r-- | src/lib/libcrypto/evp/digest.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index fd42318044..ecb5292532 100644 --- a/src/lib/libcrypto/evp/digest.c +++ b/src/lib/libcrypto/evp/digest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: digest.c,v 1.33 2022/01/09 15:15:25 tb Exp $ */ | 1 | /* $OpenBSD: digest.c,v 1.34 2022/01/10 10:51:31 tb 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 | * |
@@ -281,6 +281,8 @@ EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) | |||
281 | tmp_buf = NULL; | 281 | tmp_buf = NULL; |
282 | EVP_MD_CTX_cleanup(out); | 282 | EVP_MD_CTX_cleanup(out); |
283 | memcpy(out, in, sizeof *out); | 283 | memcpy(out, in, sizeof *out); |
284 | out->md_data = NULL; | ||
285 | out->pctx = NULL; | ||
284 | 286 | ||
285 | /* | 287 | /* |
286 | * Because of the EVP_PKEY_CTX_dup() below, EVP_MD_CTX_cleanup() needs | 288 | * Because of the EVP_PKEY_CTX_dup() below, EVP_MD_CTX_cleanup() needs |