The branch master has been updated
       via  03c2f21b980524dc05a0426146f845ec1e969c2e (commit)
       via  bb98a1123b3d7a8464f2c1f61ffd41f826c7c423 (commit)
      from  c6fcd88fa030da8322cf27aff95376512f41faff (commit)


- Log -----------------------------------------------------------------
commit 03c2f21b980524dc05a0426146f845ec1e969c2e
Author: Matt Caswell <m...@openssl.org>
Date:   Tue Jul 27 10:32:49 2021 +0100

    Add a test case for EVP_MD_meth_dup() and EVP_CIPHER_meth_dup()
    
    Check that EVP_MD_meth_free() and EVP_CIPHER_meth_free() does actually
    free the data.
    
    Reviewed-by: Dmitry Belyavskiy <beld...@gmail.com>
    Reviewed-by: Paul Dale <pa...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/16159)

commit bb98a1123b3d7a8464f2c1f61ffd41f826c7c423
Author: Matt Caswell <m...@openssl.org>
Date:   Mon Jul 26 15:53:25 2021 +0100

    Fix EVP_MD_meth_dup and EVP_CIPHER_meth_dup
    
    Make sure the origin is set correctly when duping an EVP_MD or EVP_CIPHER.
    
    Fixes #16157
    
    Reviewed-by: Dmitry Belyavskiy <beld...@gmail.com>
    Reviewed-by: Paul Dale <pa...@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/16159)

-----------------------------------------------------------------------

Summary of changes:
 crypto/evp/cmeth_lib.c |  1 +
 crypto/evp/evp_lib.c   |  1 +
 test/evp_extra_test.c  | 21 ++++++++++++++++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/crypto/evp/cmeth_lib.c b/crypto/evp/cmeth_lib.c
index 9b93550307..a806ec5f9e 100644
--- a/crypto/evp/cmeth_lib.c
+++ b/crypto/evp/cmeth_lib.c
@@ -50,6 +50,7 @@ EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
 
         memcpy(to, cipher, sizeof(*to));
         to->lock = lock;
+        to->origin = EVP_ORIG_METH;
     }
     return to;
 }
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
index f78df52ab1..64d7fb046d 100644
--- a/crypto/evp/evp_lib.c
+++ b/crypto/evp/evp_lib.c
@@ -823,6 +823,7 @@ EVP_MD *EVP_MD_meth_dup(const EVP_MD *md)
 
         memcpy(to, md, sizeof(*to));
         to->lock = lock;
+        to->origin = EVP_ORIG_METH;
     }
     return to;
 }
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index 7494c1f21b..e03e2a252e 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -3690,7 +3690,25 @@ static int test_custom_pmeth(int idx)
     custom_pmeth = NULL;
     return testresult;
 }
-#endif
+
+static int test_evp_md_cipher_meth(void)
+{
+    EVP_MD *md = EVP_MD_meth_dup(EVP_sha256());
+    EVP_CIPHER *ciph = EVP_CIPHER_meth_dup(EVP_aes_128_cbc());
+    int testresult = 0;
+
+    if (!TEST_ptr(md) || !TEST_ptr(ciph))
+        goto err;
+
+    testresult = 1;
+
+ err:
+    EVP_MD_meth_free(md);
+    EVP_CIPHER_meth_free(ciph);
+
+    return testresult;
+}
+#endif /* OPENSSL_NO_DEPRECATED_3_0 */
 
 typedef enum OPTION_choice {
     OPT_ERR = -1,
@@ -3814,6 +3832,7 @@ int setup_tests(void)
 
 #ifndef OPENSSL_NO_DEPRECATED_3_0
     ADD_ALL_TESTS(test_custom_pmeth, 12);
+    ADD_TEST(test_evp_md_cipher_meth);
 #endif
 
     return 1;

Reply via email to