[openssl] openssl-3.0 update

Dr. Paul Dale pauli at openssl.org
Mon Feb 7 00:25:32 UTC 2022


The branch openssl-3.0 has been updated
       via  25ee18e7f8803f6aaaeca15b49ba46d3e4d3f817 (commit)
      from  6e47da6363e9e32c14f0c3a750ca04cd189c85fe (commit)


- Log -----------------------------------------------------------------
commit 25ee18e7f8803f6aaaeca15b49ba46d3e4d3f817
Author: Jiasheng Jiang <jiasheng at iscas.ac.cn>
Date:   Wed Feb 2 19:45:59 2022 +0800

    evp_test: Add the missing check after calling OPENSSL_strdup and sk_OPENSSL_STRING_new_null
    
    Since the memory allocation may fail, the 'mac_name' and 'controls'
    could be NULL.
    And the 'mac_name' will be printed in mac_test_run_mac() without check.
    Also the result of 'params_n +
    sk_OPENSSL_STRING_num(expected->controls)' in
    mac_test_run_mac() will be 'params_n - 1' if allocation fails , which
    does not make sense.
    Therefore, it should be better to check them in order to guarantee the
    complete success of initiation.
    If fails, we also need to free the 'mdat' to avoid the memory leak.
    
    Signed-off-by: Jiasheng Jiang <jiasheng at iscas.ac.cn>
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/17628)
    
    (cherry picked from commit b2f90e93a07d992515782511a5770aa7cf7dc28f)

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

Summary of changes:
 test/evp_test.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/evp_test.c b/test/evp_test.c
index f2b0924e2f..5e69b37b9b 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -1181,9 +1181,18 @@ static int mac_test_init(EVP_TEST *t, const char *alg)
         return 0;
 
     mdat->type = type;
-    mdat->mac_name = OPENSSL_strdup(alg);
+    if (!TEST_ptr(mdat->mac_name = OPENSSL_strdup(alg))) {
+        OPENSSL_free(mdat);
+        return 0;
+    }
+
     mdat->mac = mac;
-    mdat->controls = sk_OPENSSL_STRING_new_null();
+    if (!TEST_ptr(mdat->controls = sk_OPENSSL_STRING_new_null())) {
+        OPENSSL_free(mdat->mac_name);
+        OPENSSL_free(mdat);
+        return 0;
+    }
+
     mdat->output_size = mdat->block_size = -1;
     t->data = mdat;
     return 1;


More information about the openssl-commits mailing list