[openssl] master update

Dr. Paul Dale pauli at openssl.org
Sat Mar 20 00:10:53 UTC 2021


The branch master has been updated
       via  07aa88cccf506c6143ec882a5dd93cd97483ecc2 (commit)
       via  77b8b49bdd01e2b1162b337941ebc70fef7030c1 (commit)
       via  bca681aa5b2539c1e50072a2034ef2f5414bb61c (commit)
       via  7153f544378eea343c61446c8fc844ae3417ca84 (commit)
       via  9b0f76e12f8de88c8709fe53e85f887485ef53f4 (commit)
       via  015b221a5fd777e1ab808ec23f03df238eaf8429 (commit)
       via  e22105d1b32eaf6ae091da3477d0434dd223cd1f (commit)
       via  65bf029d498e237c0c5b3f098b7fe932f2958e84 (commit)
       via  c0cd48fcb98d88bcc20ca322e7a11a83bf69fa51 (commit)
       via  316c8dafd4504f595ab7de59d115ce2c46a4f27f (commit)
       via  743840d56f165a56b1c4b1e50ce1e8062e49345a (commit)
       via  b573d0ceea8aa85ec6cb1e4609452f5cc405dfc8 (commit)
      from  aff442dc38707a5ab4a7acc811c9ef10cbdd3346 (commit)


- Log -----------------------------------------------------------------
commit 07aa88cccf506c6143ec882a5dd93cd97483ecc2
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 13:09:09 2021 +1000

    decoder: fix Coverity 1473236 & 1473386: resource leaks
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 77b8b49bdd01e2b1162b337941ebc70fef7030c1
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 13:04:21 2021 +1000

    apps: fix Coverity 1472670 & 1472685: resource leaks
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit bca681aa5b2539c1e50072a2034ef2f5414bb61c
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 12:59:40 2021 +1000

    rsa: fix coverity 1472658: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 7153f544378eea343c61446c8fc844ae3417ca84
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 12:57:13 2021 +1000

    evp: fix coverity 1470561: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 9b0f76e12f8de88c8709fe53e85f887485ef53f4
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 12:54:28 2021 +1000

    test: fix coverity 1470559: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 015b221a5fd777e1ab808ec23f03df238eaf8429
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:58:30 2021 +1000

    test: fix coverity 1455330, 1455332, 1455334, 1455342, 1455344 : resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit e22105d1b32eaf6ae091da3477d0434dd223cd1f
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:48:09 2021 +1000

    ssl: fix coverity 1451495: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 65bf029d498e237c0c5b3f098b7fe932f2958e84
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:45:35 2021 +1000

    test: fix coverity 1414449 & 1414471: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit c0cd48fcb98d88bcc20ca322e7a11a83bf69fa51
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:39:25 2021 +1000

    test: fix coverity 1414445: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 316c8dafd4504f595ab7de59d115ce2c46a4f27f
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:31:33 2021 +1000

    test: fix coverity 1454040: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit 743840d56f165a56b1c4b1e50ce1e8062e49345a
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:29:05 2021 +1000

    test: fix coverity 1451562: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

commit b573d0ceea8aa85ec6cb1e4609452f5cc405dfc8
Author: Pauli <ppzgs1 at gmail.com>
Date:   Thu Mar 18 10:26:22 2021 +1000

    test: fix coverity 1451553: resource leak
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14596)

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

Summary of changes:
 apps/ocsp.c                                     | 10 ++--
 crypto/encode_decode/decoder_pkey.c             |  5 ++
 crypto/evp/pmeth_lib.c                          |  1 +
 providers/implementations/asymciphers/rsa_enc.c |  2 +
 ssl/ssl_ciph.c                                  |  4 +-
 test/cmp_asn_test.c                             |  9 ++--
 test/cmp_hdr_test.c                             | 59 +++++++++++++++-------
 test/exdatatest.c                               | 66 ++++++++++++++-----------
 test/moduleloadtest.c                           | 12 +++--
 test/params_api_test.c                          |  4 +-
 test/shlibloadtest.c                            |  6 +++
 test/threadstest.c                              |  8 +--
 12 files changed, 118 insertions(+), 68 deletions(-)

diff --git a/apps/ocsp.c b/apps/ocsp.c
index e77c90f041..bd509d98a7 100644
--- a/apps/ocsp.c
+++ b/apps/ocsp.c
@@ -241,14 +241,10 @@ int ocsp_main(int argc, char **argv)
     unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
     OPTION_CHOICE o;
 
-    reqnames = sk_OPENSSL_STRING_new_null();
-    if (reqnames == NULL)
+    if ((reqnames = sk_OPENSSL_STRING_new_null()) == NULL
+            || (ids = sk_OCSP_CERTID_new_null()) == NULL
+            || (vpm = X509_VERIFY_PARAM_new()) == NULL)
         goto end;
-    ids = sk_OCSP_CERTID_new_null();
-    if (ids == NULL)
-        goto end;
-    if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
-        return 1;
 
     prog = opt_init(argc, argv, ocsp_options);
     while ((o = opt_next()) != OPT_EOF) {
diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c
index 38764b418b..08deb2d088 100644
--- a/crypto/encode_decode/decoder_pkey.c
+++ b/crypto/encode_decode/decoder_pkey.c
@@ -312,6 +312,7 @@ int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
         EVP_KEYMGMT_free(keymgmt);
     }
     sk_EVP_KEYMGMT_free(keymgmts);
+    keymgmts = NULL;
 
     /*
      * Finally, find all decoders that have any keymgmt of the collected
@@ -325,6 +326,7 @@ int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
         OSSL_DECODER_do_all_provided(libctx,
                                      collect_decoder, &collect_decoder_data);
         sk_OPENSSL_CSTRING_free(names);
+        names = NULL;
 
         if (collect_decoder_data.error_occurred)
             goto err;
@@ -343,6 +345,9 @@ int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
     ok = 1;
  err:
     decoder_clean_pkey_construct_arg(process_data);
+    sk_EVP_KEYMGMT_pop_free(keymgmts, EVP_KEYMGMT_free);
+    sk_OPENSSL_CSTRING_free(names);
+
     return ok;
 }
 
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index 96d103544d..f145bdfdc6 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -313,6 +313,7 @@ static EVP_PKEY_CTX *int_ctx_new(OSSL_LIB_CTX *libctx,
     if (propquery != NULL) {
         ret->propquery = OPENSSL_strdup(propquery);
         if (ret->propquery == NULL) {
+            OPENSSL_free(ret);
             EVP_KEYMGMT_free(keymgmt);
             return NULL;
         }
diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c
index 34ce13dd30..621239d79e 100644
--- a/providers/implementations/asymciphers/rsa_enc.c
+++ b/providers/implementations/asymciphers/rsa_enc.c
@@ -250,6 +250,7 @@ static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
             if (prsactx->oaep_md == NULL) {
                 prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
                 if (prsactx->oaep_md == NULL) {
+                    OPENSSL_free(tbuf);
                     ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
                     return 0;
                 }
@@ -264,6 +265,7 @@ static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
             /* RSA_PKCS1_WITH_TLS_PADDING */
             if (prsactx->client_version <= 0) {
                 ERR_raise(ERR_LIB_PROV, PROV_R_BAD_TLS_CLIENT_VERSION);
+                OPENSSL_free(tbuf);
                 return 0;
             }
             ret = ossl_rsa_padding_check_PKCS1_type_2_TLS(
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index 0b6f01ccc1..80014a31fd 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -1384,8 +1384,10 @@ static int update_cipher_list(STACK_OF(SSL_CIPHER) **cipher_list,
         sk_SSL_CIPHER_insert(tmp_cipher_list,
                              sk_SSL_CIPHER_value(tls13_ciphersuites, i), i);
 
-    if (!update_cipher_list_by_id(cipher_list_by_id, tmp_cipher_list))
+    if (!update_cipher_list_by_id(cipher_list_by_id, tmp_cipher_list)) {
+        sk_SSL_CIPHER_free(tmp_cipher_list);
         return 0;
+    }
 
     sk_SSL_CIPHER_free(*cipher_list);
     *cipher_list = tmp_cipher_list;
diff --git a/test/cmp_asn_test.c b/test/cmp_asn_test.c
index 33cc03cb4c..c021ed03a6 100644
--- a/test/cmp_asn_test.c
+++ b/test/cmp_asn_test.c
@@ -42,12 +42,15 @@ static void tear_down(CMP_ASN_TEST_FIXTURE *fixture)
 
 static int execute_cmp_asn1_get_int_test(CMP_ASN_TEST_FIXTURE *fixture)
 {
+    int res;
     ASN1_INTEGER *asn1integer = ASN1_INTEGER_new();
-    ASN1_INTEGER_set(asn1integer, 77);
-    if (!TEST_int_eq(77, ossl_cmp_asn1_get_int(asn1integer)))
+
+    if (!TEST_ptr(asn1integer))
         return 0;
+    ASN1_INTEGER_set(asn1integer, 77);
+    res = TEST_int_eq(77, ossl_cmp_asn1_get_int(asn1integer));
     ASN1_INTEGER_free(asn1integer);
-    return 1;
+    return res;
 }
 
 static int test_cmp_asn1_get_int(void)
diff --git a/test/cmp_hdr_test.c b/test/cmp_hdr_test.c
index 17f38377b5..617d78012f 100644
--- a/test/cmp_hdr_test.c
+++ b/test/cmp_hdr_test.c
@@ -190,21 +190,23 @@ static int test_HDR_update_messageTime(void)
 static int execute_HDR_set1_senderKID_test(CMP_HDR_TEST_FIXTURE *fixture)
 {
     ASN1_OCTET_STRING *senderKID = ASN1_OCTET_STRING_new();
+    int res = 0;
 
     if (!TEST_ptr(senderKID))
         return 0;
 
     if (!TEST_int_eq(ASN1_OCTET_STRING_set(senderKID, rand_data,
                                            sizeof(rand_data)), 1))
-        return 0;
+        goto err;
     if (!TEST_int_eq(ossl_cmp_hdr_set1_senderKID(fixture->hdr, senderKID), 1))
-        return 0;
+        goto err;
     if (!TEST_int_eq(ASN1_OCTET_STRING_cmp(fixture->hdr->senderKID,
                                            senderKID), 0))
-        return 0;
-
+        goto err;
+    res = 1;
+ err:
     ASN1_OCTET_STRING_free(senderKID);
-    return 1;
+    return res;
 }
 
 static int test_HDR_set1_senderKID(void)
@@ -223,15 +225,19 @@ static int execute_HDR_push0_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
         return 0;
 
     if (!ASN1_STRING_set(text, "A free text", -1))
-        return 0;
+        goto err;
 
     if (!TEST_int_eq(ossl_cmp_hdr_push0_freeText(fixture->hdr, text), 1))
-        return 0;
+        goto err;
 
     if (!TEST_true(text == sk_ASN1_UTF8STRING_value(fixture->hdr->freeText, 0)))
-        return 0;
+        goto err;
 
     return 1;
+
+ err:
+    ASN1_UTF8STRING_free(text);
+    return 0;
 }
 
 static int test_HDR_push0_freeText(void)
@@ -246,22 +252,25 @@ static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
 {
     ASN1_UTF8STRING *text = ASN1_UTF8STRING_new();
     ASN1_UTF8STRING *pushed_text;
+    int res = 0;
 
     if (!TEST_ptr(text))
         return 0;
 
     if (!ASN1_STRING_set(text, "A free text", -1))
-        return 0;
+        goto err;
 
     if (!TEST_int_eq(ossl_cmp_hdr_push1_freeText(fixture->hdr, text), 1))
-        return 0;
+        goto err;
 
     pushed_text = sk_ASN1_UTF8STRING_value(fixture->hdr->freeText, 0);
     if (!TEST_int_eq(ASN1_STRING_cmp(text, pushed_text), 0))
-        return 0;
+        goto err;
 
+    res = 1;
+ err:
     ASN1_UTF8STRING_free(text);
-    return 1;
+    return res;
 }
 
 static int test_HDR_push1_freeText(void)
@@ -309,33 +318,45 @@ execute_HDR_generalInfo_push1_items_test(CMP_HDR_TEST_FIXTURE *fixture)
     ASN1_INTEGER *asn1int = ASN1_INTEGER_new();
     ASN1_TYPE *val = ASN1_TYPE_new();
     ASN1_TYPE *pushed_val;
+    int res = 0;
 
     if (!TEST_ptr(asn1int))
         return 0;
 
-    if (!TEST_ptr(val))
+    if (!TEST_ptr(val)) {
+        ASN1_INTEGER_free(asn1int);
         return 0;
+    }
 
     ASN1_INTEGER_set(asn1int, 88);
     ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int);
-    itav = OSSL_CMP_ITAV_create(OBJ_txt2obj(oid, 1), val);
-    OSSL_CMP_ITAV_push0_stack_item(&itavs, itav);
+    if (!TEST_ptr(itav = OSSL_CMP_ITAV_create(OBJ_txt2obj(oid, 1), val))) {
+        ASN1_TYPE_free(val);
+        return 0;
+    }
+    if (!TEST_true(OSSL_CMP_ITAV_push0_stack_item(&itavs, itav))) {
+        OSSL_CMP_ITAV_free(itav);
+        return 0;
+    }
 
     if (!TEST_int_eq(ossl_cmp_hdr_generalInfo_push1_items(fixture->hdr, itavs),
                      1))
-        return 0;
+        goto err;
     ginfo = fixture->hdr->generalInfo;
     pushed_itav = sk_OSSL_CMP_ITAV_value(ginfo, 0);
     OBJ_obj2txt(buf, sizeof(buf), OSSL_CMP_ITAV_get0_type(pushed_itav), 0);
     if (!TEST_int_eq(memcmp(oid, buf, sizeof(oid)), 0))
-        return 0;
+        goto err;
 
     pushed_val = OSSL_CMP_ITAV_get0_value(sk_OSSL_CMP_ITAV_value(ginfo, 0));
     if (!TEST_int_eq(ASN1_TYPE_cmp(itav->infoValue.other, pushed_val), 0))
-        return 0;
+        goto err;
+
+    res = 1;
 
+ err:
     sk_OSSL_CMP_ITAV_pop_free(itavs, OSSL_CMP_ITAV_free);
-    return 1;
+    return res;
 }
 
 static int test_HDR_generalInfo_push1_items(void)
diff --git a/test/exdatatest.c b/test/exdatatest.c
index 8dd9261d25..dfccb6f0d1 100644
--- a/test/exdatatest.c
+++ b/test/exdatatest.c
@@ -135,8 +135,10 @@ static MYOBJ *MYOBJ_new(void)
     static int count = 0;
     MYOBJ *obj = OPENSSL_malloc(sizeof(*obj));
 
-    obj->id = ++count;
-    obj->st = CRYPTO_new_ex_data(CRYPTO_EX_INDEX_APP, obj, &obj->ex_data);
+    if (obj != NULL) {
+        obj->id = ++count;
+        obj->st = CRYPTO_new_ex_data(CRYPTO_EX_INDEX_APP, obj, &obj->ex_data);
+    }
     return obj;
 }
 
@@ -199,31 +201,37 @@ static char *MYOBJ_gethello3(MYOBJ *obj)
 
 static void MYOBJ_free(MYOBJ *obj)
 {
-    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_APP, obj, &obj->ex_data);
-    OPENSSL_free(obj);
+    if (obj != NULL) {
+        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_APP, obj, &obj->ex_data);
+        OPENSSL_free(obj);
+    }
 }
 
 static MYOBJ *MYOBJ_dup(MYOBJ *in)
 {
     MYOBJ *obj = MYOBJ_new();
 
-    obj->st |= CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_APP, &obj->ex_data,
-                                 &in->ex_data);
+    if (obj != NULL)
+        obj->st |= CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_APP, &obj->ex_data,
+                                     &in->ex_data);
     return obj;
 }
 
 static int test_exdata(void)
 {
-    MYOBJ *t1, *t2, *t3;
-    MYOBJ_EX_DATA *ex_data;
+    MYOBJ *t1 = NULL, *t2 = NULL, *t3 = NULL;
+    MYOBJ_EX_DATA *ex_data = NULL;
     const char *cp;
     char *p;
+    int res = 0;
 
     gbl_result = 1;
 
-    p = OPENSSL_strdup("hello world");
+    if (!TEST_ptr(p = OPENSSL_strdup("hello world")))
+        return 0;
     saved_argl = 21;
-    saved_argp = OPENSSL_malloc(1);
+    if (!TEST_ptr(saved_argp = OPENSSL_malloc(1)))
+        goto err;
     saved_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
                                         saved_argl, saved_argp,
                                         exnew, exdup, exfree);
@@ -233,9 +241,9 @@ static int test_exdata(void)
     t1 = MYOBJ_new();
     t2 = MYOBJ_new();
     if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))
-        return 0;
+        goto err;
     if (!TEST_ptr(CRYPTO_get_ex_data(&t1->ex_data, saved_idx2)))
-        return 0;
+        goto err;
 
     /*
      * saved_idx3 differs from other indexes by being created after the exdata
@@ -245,63 +253,63 @@ static int test_exdata(void)
                                          saved_argl, saved_argp,
                                          exnew2, exdup2, exfree2);
     if (!TEST_ptr_null(CRYPTO_get_ex_data(&t1->ex_data, saved_idx3)))
-        return 0;
+        goto err;
 
     MYOBJ_sethello(t1, p);
     cp = MYOBJ_gethello(t1);
     if (!TEST_ptr_eq(cp, p))
-        return 0;
+        goto err;
 
     MYOBJ_sethello2(t1, p);
     cp = MYOBJ_gethello2(t1);
     if (!TEST_ptr_eq(cp, p))
-        return 0;
+        goto err;
 
     MYOBJ_allochello3(t1, p);
     cp = MYOBJ_gethello3(t1);
     if (!TEST_ptr_eq(cp, p))
-        return 0;
+        goto err;
 
     cp = MYOBJ_gethello(t2);
     if (!TEST_ptr_null(cp))
-        return 0;
+        goto err;
 
     cp = MYOBJ_gethello2(t2);
     if (!TEST_ptr_null(cp))
-        return 0;
+        goto err;
 
     t3 = MYOBJ_dup(t1);
     if (!TEST_int_eq(t3->st, 1))
-        return 0;
+        goto err;
 
     ex_data = CRYPTO_get_ex_data(&t3->ex_data, saved_idx2);
     if (!TEST_ptr(ex_data))
-        return 0;
+        goto err;
     if (!TEST_int_eq(ex_data->dup, 1))
-        return 0;
+        goto err;
 
     cp = MYOBJ_gethello(t3);
     if (!TEST_ptr_eq(cp, p))
-        return 0;
+        goto err;
 
     cp = MYOBJ_gethello2(t3);
     if (!TEST_ptr_eq(cp, p))
-        return 0;
+        goto err;
 
     cp = MYOBJ_gethello3(t3);
     if (!TEST_ptr_eq(cp, p))
-        return 0;
+        goto err;
 
+    if (gbl_result)
+        res = 1;
+ err:
     MYOBJ_free(t1);
     MYOBJ_free(t2);
     MYOBJ_free(t3);
     OPENSSL_free(saved_argp);
+    saved_argp = NULL;
     OPENSSL_free(p);
-
-    if (gbl_result)
-      return 1;
-    else
-      return 0;
+    return res;
 }
 
 int setup_tests(void)
diff --git a/test/moduleloadtest.c b/test/moduleloadtest.c
index 915343f055..2ad0dac752 100644
--- a/test/moduleloadtest.c
+++ b/test/moduleloadtest.c
@@ -23,10 +23,14 @@ static int test_load(const char *path, const char *symbol)
 #ifdef SD_INIT
     SD sd = SD_INIT;
     SD_SYM sym;
-
-    return sd_load(path, &sd, SD_MODULE)
-        && (symbol == NULL || sd_sym(sd, symbol, &sym))
-        && sd_close(sd);
+    int ret;
+
+    if (!sd_load(path, &sd, SD_MODULE))
+        return 0;
+    ret = symbol == NULL || sd_sym(sd, symbol, &sym);
+    if (!sd_close(sd))
+        ret = 0;
+    return ret;
 #else
     fprintf(stderr, "No dynamic loader\n");
     return 0;
diff --git a/test/params_api_test.c b/test/params_api_test.c
index c1dbdad129..e47c2643ad 100644
--- a/test/params_api_test.c
+++ b/test/params_api_test.c
@@ -540,8 +540,10 @@ static int test_param_construct(void)
         || !TEST_true(OSSL_PARAM_set_utf8_string(cp, "abcdef"))
         || !TEST_size_t_eq(cp->return_size, sizeof("abcdef") - 1)
         || !TEST_true(OSSL_PARAM_get_utf8_string(cp, &bufp, 0))
-        || !TEST_str_eq(bufp, "abcdef"))
+        || !TEST_str_eq(bufp, "abcdef")) {
+        OPENSSL_free(bufp);
         goto err;
+    }
     OPENSSL_free(bufp);
     bufp = buf2;
     if (!TEST_true(OSSL_PARAM_get_utf8_string(cp, &bufp, sizeof(buf2)))
diff --git a/test/shlibloadtest.c b/test/shlibloadtest.c
index c879e9a01e..8d3c87d36c 100644
--- a/test/shlibloadtest.c
+++ b/test/shlibloadtest.c
@@ -208,12 +208,14 @@ static int test_lib(void)
         fprintf(stderr, "Failed to close libcrypto\n");
         goto end;
     }
+    cryptolib = SD_INIT;
 
     if (test_type == CRYPTO_FIRST || test_type == SSL_FIRST) {
         if (!sd_close(ssllib)) {
             fprintf(stderr, "Failed to close libssl\n");
             goto end;
         }
+        ssllib = SD_INIT;
     }
 
 # if defined(OPENSSL_NO_PINSHARED) \
@@ -235,6 +237,10 @@ static int test_lib(void)
 
     result = 1;
 end:
+    if (cryptolib != SD_INIT)
+        sd_close(cryptolib);
+    if (ssllib != SD_INIT)
+        sd_close(ssllib);
     return result;
 }
 #endif
diff --git a/test/threadstest.c b/test/threadstest.c
index 5b64246881..ed46234fc1 100644
--- a/test/threadstest.c
+++ b/test/threadstest.c
@@ -93,14 +93,14 @@ static int wait_for_thread(thread_t thread)
 static int test_lock(void)
 {
     CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
+    int res;
 
-    if (!TEST_true(CRYPTO_THREAD_read_lock(lock))
-        || !TEST_true(CRYPTO_THREAD_unlock(lock)))
-        return 0;
+    res = TEST_true(CRYPTO_THREAD_read_lock(lock))
+          && TEST_true(CRYPTO_THREAD_unlock(lock));
 
     CRYPTO_THREAD_lock_free(lock);
 
-    return 1;
+    return res;
 }
 
 static CRYPTO_ONCE once_run = CRYPTO_ONCE_STATIC_INIT;


More information about the openssl-commits mailing list