diff options
| author | tb <> | 2022-01-10 10:51:31 +0000 |
|---|---|---|
| committer | tb <> | 2022-01-10 10:51:31 +0000 |
| commit | b1042d763c8d1442a3bbd1098fe10bbb13206ca4 (patch) | |
| tree | e06f01c1949048520df738b0696be8e54d046570 | |
| parent | be9e6959fcd7a339f12f1570a179ccf30f61d5fe (diff) | |
| download | openbsd-b1042d763c8d1442a3bbd1098fe10bbb13206ca4.tar.gz openbsd-b1042d763c8d1442a3bbd1098fe10bbb13206ca4.tar.bz2 openbsd-b1042d763c8d1442a3bbd1098fe10bbb13206ca4.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
Diffstat (limited to '')
| -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 |
