summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index a229901956..38605a6fe1 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_enc.c,v 1.40 2019/03/17 18:07:41 tb Exp $ */ 1/* $OpenBSD: evp_enc.c,v 1.41 2019/04/14 16:43:49 jsing 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 *
@@ -674,8 +674,21 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
674 memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size); 674 memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
675 } 675 }
676 676
677 if (in->cipher->flags & EVP_CIPH_CUSTOM_COPY) 677 if (in->cipher->flags & EVP_CIPH_CUSTOM_COPY) {
678 return in->cipher->ctrl((EVP_CIPHER_CTX *)in, 678 if (!in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY,
679 EVP_CTRL_COPY, 0, out); 679 0, out)) {
680 /*
681 * If the custom copy control failed, assume that there
682 * may still be pointers copied in the cipher_data that
683 * we do not own. This may result in a leak from a bad
684 * custom copy control, but that's preferable to a
685 * double free...
686 */
687 freezero(out->cipher_data, in->cipher->ctx_size);
688 out->cipher_data = NULL;
689 return 0;
690 }
691 }
692
680 return 1; 693 return 1;
681} 694}