[openssl] master update

shane.lontis at oracle.com shane.lontis at oracle.com
Sat Sep 5 05:46:49 UTC 2020


The branch master has been updated
       via  59ed73398920a9ad663da03a08cfd290995f55af (commit)
       via  5340c8ea2a25d17ee2ce1f35d1fb545b8487e84b (commit)
       via  776cf98b493768de02f798f71f6b30c40deb3506 (commit)
       via  d135774e7d4304df90eab0ed37e93ecdfb1b99a9 (commit)
       via  33200269110f0ed4a9c96be03b32cd8913f9e426 (commit)
       via  0e540f231cbdc8e24e1496cf8ac265b62a983692 (commit)
       via  7ce49eeaca2081ccd881fc1b22fac2d08d3bb69a (commit)
       via  ea478697927798ff2850ea94b4938bb0c76da48b (commit)
      from  d55d0935deb1a8af9cb9a76bf4ca21da47ba8184 (commit)


- Log -----------------------------------------------------------------
commit 59ed73398920a9ad663da03a08cfd290995f55af
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 12:52:56 2020 +1000

    Fix coverity CID #1454815 - NULL ptr dereference in initthread.c
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit 5340c8ea2a25d17ee2ce1f35d1fb545b8487e84b
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 12:45:50 2020 +1000

    Fix coverity CID #1452769 & #1452771 - Arg passed to function that cannot be negative in cms_ess.c
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit 776cf98b493768de02f798f71f6b30c40deb3506
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 12:16:24 2020 +1000

    Fix coverity CID #1457935 - Check return value in ffc_params.c for BIO_indent/BIO_puts calls.
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit d135774e7d4304df90eab0ed37e93ecdfb1b99a9
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 12:02:02 2020 +1000

    Fix coverity CID #1465967 & #1465968 - fix NULL dereference in dh_ameth.c
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit 33200269110f0ed4a9c96be03b32cd8913f9e426
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 11:57:12 2020 +1000

    Fix coverity CID #1466371 - fix dereference before NULL check.
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit 0e540f231cbdc8e24e1496cf8ac265b62a983692
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 11:45:57 2020 +1000

    Fix coverity CID #1466375 - Remove dead code.
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit 7ce49eeaca2081ccd881fc1b22fac2d08d3bb69a
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 11:32:48 2020 +1000

    Fix coverity CID #1466377 - resource leak due to early return in ec_get_params().
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

commit ea478697927798ff2850ea94b4938bb0c76da48b
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Mon Aug 24 11:29:23 2020 +1000

    Fix coverity CID #1466378 - Incorrect expression in ec_backend.c
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    (Merged from https://github.com/openssl/openssl/pull/12708)

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

Summary of changes:
 crypto/cms/cms_ess.c                               |  8 +++---
 crypto/dh/dh_ameth.c                               |  5 ++--
 crypto/ec/ec_backend.c                             |  2 +-
 crypto/ffc/ffc_params.c                            | 10 +++++---
 crypto/initthread.c                                |  3 ++-
 .../implementations/encode_decode/encoder_ec.c     | 29 ++++++++++------------
 providers/implementations/keymgmt/ec_kmgmt.c       | 19 ++++++++------
 7 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c
index 3e545b7add..b6b2037532 100644
--- a/crypto/cms/cms_ess.c
+++ b/crypto/cms/cms_ess.c
@@ -430,12 +430,12 @@ ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si)
 int cms_add1_signing_cert_v2(CMS_SignerInfo *si, ESS_SIGNING_CERT_V2 *sc)
 {
     ASN1_STRING *seq = NULL;
-    unsigned char *p, *pp;
+    unsigned char *p, *pp = NULL;
     int len;
 
     /* Add SigningCertificateV2 signed attribute to the signer info. */
     len = i2d_ESS_SIGNING_CERT_V2(sc, NULL);
-    if ((pp = OPENSSL_malloc(len)) == NULL)
+    if (len <= 0 || (pp = OPENSSL_malloc(len)) == NULL)
         goto err;
     p = pp;
     i2d_ESS_SIGNING_CERT_V2(sc, &p);
@@ -462,12 +462,12 @@ int cms_add1_signing_cert_v2(CMS_SignerInfo *si, ESS_SIGNING_CERT_V2 *sc)
 int cms_add1_signing_cert(CMS_SignerInfo *si, ESS_SIGNING_CERT *sc)
 {
     ASN1_STRING *seq = NULL;
-    unsigned char *p, *pp;
+    unsigned char *p, *pp = NULL;
     int len;
 
     /* Add SigningCertificate signed attribute to the signer info. */
     len = i2d_ESS_SIGNING_CERT(sc, NULL);
-    if ((pp = OPENSSL_malloc(len)) == NULL)
+    if (len <= 0 || (pp = OPENSSL_malloc(len)) == NULL)
         goto err;
     p = pp;
     i2d_ESS_SIGNING_CERT(sc, &p);
diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c
index 011bc5ad03..3d4605ae11 100644
--- a/crypto/dh/dh_ameth.c
+++ b/crypto/dh/dh_ameth.c
@@ -564,13 +564,12 @@ static int dh_pkey_import_from_type(const OSSL_PARAM params[], void *vpctx,
     EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(pctx);
     DH *dh = dh_new_with_libctx(pctx->libctx);
 
-    DH_clear_flags(dh, DH_FLAG_TYPE_MASK);
-    DH_set_flags(dh, type == EVP_PKEY_DH ? DH_FLAG_TYPE_DH : DH_FLAG_TYPE_DHX);
-
     if (dh == NULL) {
         ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE);
         return 0;
     }
+    DH_clear_flags(dh, DH_FLAG_TYPE_MASK);
+    DH_set_flags(dh, type == EVP_PKEY_DH ? DH_FLAG_TYPE_DH : DH_FLAG_TYPE_DHX);
 
     if (!dh_ffc_params_fromdata(dh, params)
         || !dh_key_fromdata(dh, params)
diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c
index 1599e2b1f3..8acbcebd6f 100644
--- a/crypto/ec/ec_backend.c
+++ b/crypto/ec/ec_backend.c
@@ -162,7 +162,7 @@ int ec_group_todata(const EC_GROUP *group, OSSL_PARAM_BLD *tmpl,
 #endif
     } else {
         /* named curve */
-        const char *curve_name = curve_name = ec_curve_nid2name(curve_nid);
+        const char *curve_name = ec_curve_nid2name(curve_nid);
 
         if (curve_name == NULL
             || !ossl_param_build_set_utf8_string(tmpl, params,
diff --git a/crypto/ffc/ffc_params.c b/crypto/ffc/ffc_params.c
index ac767c0a1c..c980ea0018 100644
--- a/crypto/ffc/ffc_params.c
+++ b/crypto/ffc/ffc_params.c
@@ -313,8 +313,10 @@ int ffc_params_print(BIO *bp, const FFC_PARAMS *ffc, int indent)
         goto err;
     if (ffc->seed != NULL) {
         size_t i;
-        BIO_indent(bp, indent, 128);
-        BIO_puts(bp, "seed:");
+
+        if (!BIO_indent(bp, indent, 128)
+            || BIO_puts(bp, "seed:") <= 0)
+            goto err;
         for (i = 0; i < ffc->seedlen; i++) {
             if ((i % 15) == 0) {
                 if (BIO_puts(bp, "\n") <= 0
@@ -329,8 +331,8 @@ int ffc_params_print(BIO *bp, const FFC_PARAMS *ffc, int indent)
             return 0;
     }
     if (ffc->pcounter != -1) {
-        BIO_indent(bp, indent, 128);
-        if (BIO_printf(bp, "counter: %d\n", ffc->pcounter) <= 0)
+        if (!BIO_indent(bp, indent, 128)
+            || BIO_printf(bp, "counter: %d\n", ffc->pcounter) <= 0)
             goto err;
     }
     return 1;
diff --git a/crypto/initthread.c b/crypto/initthread.c
index c9a34a77db..5ad38dfee2 100644
--- a/crypto/initthread.c
+++ b/crypto/initthread.c
@@ -392,13 +392,14 @@ static int init_thread_deregister(void *index, int all)
     for (i = 0; i < sk_THREAD_EVENT_HANDLER_PTR_num(gtr->skhands); i++) {
         THREAD_EVENT_HANDLER **hands
             = sk_THREAD_EVENT_HANDLER_PTR_value(gtr->skhands, i);
-        THREAD_EVENT_HANDLER *curr = *hands, *prev = NULL, *tmp;
+        THREAD_EVENT_HANDLER *curr = NULL, *prev = NULL, *tmp;
 
         if (hands == NULL) {
             if (!all)
                 CRYPTO_THREAD_unlock(gtr->lock);
             return 0;
         }
+        curr = *hands;
         while (curr != NULL) {
             if (all || curr->index == index) {
                 if (prev != NULL)
diff --git a/providers/implementations/encode_decode/encoder_ec.c b/providers/implementations/encode_decode/encoder_ec.c
index ee64e2f802..ab8e82eb6e 100644
--- a/providers/implementations/encode_decode/encoder_ec.c
+++ b/providers/implementations/encode_decode/encoder_ec.c
@@ -69,23 +69,20 @@ static int ossl_prov_print_ec_param_explicit_gen(BIO *out,
         || EC_POINT_point2bn(group, point, form, gen, ctx) == NULL)
         return 0;
 
-    if (gen != NULL) {
-        switch (form) {
-        case POINT_CONVERSION_COMPRESSED:
-           glabel = "Generator (compressed):";
-           break;
-        case POINT_CONVERSION_UNCOMPRESSED:
-            glabel = "Generator (uncompressed):";
-            break;
-        case POINT_CONVERSION_HYBRID:
-            glabel = "Generator (hybrid):";
-            break;
-        default:
-            return 0;
-        }
-        return ossl_prov_print_labeled_bignum(out, glabel, gen);
+    switch (form) {
+    case POINT_CONVERSION_COMPRESSED:
+       glabel = "Generator (compressed):";
+       break;
+    case POINT_CONVERSION_UNCOMPRESSED:
+        glabel = "Generator (uncompressed):";
+        break;
+    case POINT_CONVERSION_HYBRID:
+        glabel = "Generator (hybrid):";
+        break;
+    default:
+        return 0;
     }
-    return 1;
+    return ossl_prov_print_labeled_bignum(out, glabel, gen);
 }
 
 /* Print explicit parameters */
diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c
index cb5e2291da..9c2e627e37 100644
--- a/providers/implementations/keymgmt/ec_kmgmt.c
+++ b/providers/implementations/keymgmt/ec_kmgmt.c
@@ -321,7 +321,7 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
               void *cbarg)
 {
     EC_KEY *ec = keydata;
-    OSSL_PARAM_BLD *tmpl;
+    OSSL_PARAM_BLD *tmpl = NULL;
     OSSL_PARAM *params = NULL;
     unsigned char *pub_key = NULL, *genbuf = NULL;
     BN_CTX *bnctx = NULL;
@@ -358,8 +358,11 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
 
     if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {
         bnctx = BN_CTX_new_ex(ec_key_get_libctx(ec));
+        if (bnctx == NULL) {
+            ok = 0;
+            goto end;
+        }
         BN_CTX_start(bnctx);
-        ok = ok && (bnctx != NULL);
         ok = ok && ec_group_todata(EC_KEY_get0_group(ec), tmpl, NULL,
                                    ec_key_get_libctx(ec), ec_key_get0_propq(ec),
                                    bnctx, &genbuf);
@@ -376,7 +379,7 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
 
     if (ok && (params = OSSL_PARAM_BLD_to_param(tmpl)) != NULL)
         ok = param_cb(params, cbarg);
-
+end:
     OSSL_PARAM_BLD_free_params(params);
     OSSL_PARAM_BLD_free(tmpl);
     OPENSSL_free(pub_key);
@@ -526,10 +529,10 @@ int ec_get_params(void *key, OSSL_PARAM params[])
 
     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL
         && !OSSL_PARAM_set_int(p, ECDSA_size(eck)))
-        return 0;
+        goto err;
     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL
         && !OSSL_PARAM_set_int(p, EC_GROUP_order_bits(ecg)))
-        return 0;
+        goto err;
     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL) {
         int ecbits, sec_bits;
 
@@ -565,12 +568,12 @@ int ec_get_params(void *key, OSSL_PARAM params[])
             sec_bits = ecbits / 2;
 
         if (!OSSL_PARAM_set_int(p, sec_bits))
-            return 0;
+            goto err;
     }
 
     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
         && !OSSL_PARAM_set_utf8_string(p, EC_DEFAULT_MD))
-        return 0;
+        goto err;
 
     p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH);
     if (p != NULL) {
@@ -580,7 +583,7 @@ int ec_get_params(void *key, OSSL_PARAM params[])
             (EC_KEY_get_flags(eck) & EC_FLAG_COFACTOR_ECDH) ? 1 : 0;
 
         if (!OSSL_PARAM_set_int(p, ecdh_cofactor_mode))
-            return 0;
+            goto err;
     }
     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_TLS_ENCODED_PT)) != NULL) {
         p->return_size = EC_POINT_point2oct(EC_KEY_get0_group(key),


More information about the openssl-commits mailing list