[openssl] master update

tomas at openssl.org tomas at openssl.org
Thu Apr 22 14:46:40 UTC 2021


The branch master has been updated
       via  1fac27050176f7ed00da5649266024265678f70c (commit)
       via  db6b1266ab30945de2d14fbc62e9c3c308cce897 (commit)
       via  59088414bc3b863a3dc287de76c53464bd7ff6fa (commit)
      from  6b2978406d050b910a889a33f7a0e14b1217976d (commit)


- Log -----------------------------------------------------------------
commit 1fac27050176f7ed00da5649266024265678f70c
Author: Tomas Mraz <tomas at openssl.org>
Date:   Mon Apr 19 16:02:16 2021 +0200

    Fix potential NULL dereference in OSSL_PARAM_get_utf8_string()
    
    Fixes Coverity ID 1476283
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14928)

commit db6b1266ab30945de2d14fbc62e9c3c308cce897
Author: Tomas Mraz <tomas at openssl.org>
Date:   Mon Apr 19 15:50:35 2021 +0200

    Fix potential NULL dereference in ossl_ec_key_dup()
    
    Fixes Coverity ID 1476282
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14928)

commit 59088414bc3b863a3dc287de76c53464bd7ff6fa
Author: Tomas Mraz <tomas at openssl.org>
Date:   Mon Apr 19 15:34:59 2021 +0200

    Removed dead code in linebuffer_ctrl()
    
    Fixes Coverity CID 1476284
    
    Also add possible number truncation check.
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14928)

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

Summary of changes:
 crypto/bio/bf_lbuf.c   |  6 +++---
 crypto/ec/ec_backend.c | 12 ++++++------
 crypto/params.c        |  4 +++-
 test/evp_extra_test2.c |  2 +-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c
index e9b946fe87..946ff0d23b 100644
--- a/crypto/bio/bf_lbuf.c
+++ b/crypto/bio/bf_lbuf.c
@@ -232,12 +232,12 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
         }
         break;
     case BIO_C_SET_BUFF_SIZE:
+        if (num > INT_MAX)
+            return 0;
         obs = (int)num;
         p = ctx->obuf;
         if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) {
-            if (num <= 0)
-                return 0;
-            p = OPENSSL_malloc((size_t)num);
+            p = OPENSSL_malloc((size_t)obs);
             if (p == NULL)
                 goto malloc_error;
         }
diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c
index e9843eb4ac..581c006fd0 100644
--- a/crypto/ec/ec_backend.c
+++ b/crypto/ec/ec_backend.c
@@ -532,17 +532,17 @@ int ossl_ec_key_is_foreign(const EC_KEY *ec)
 
 EC_KEY *ossl_ec_key_dup(const EC_KEY *src, int selection)
 {
-    EC_KEY *ret = ossl_ec_key_new_method_int(src->libctx, src->propq,
-                                             src->engine);
-
-    if (ret == NULL)
-        return NULL;
+    EC_KEY *ret;
 
     if (src == NULL) {
         ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
-        goto err;
+        return NULL;
     }
 
+    if ((ret = ossl_ec_key_new_method_int(src->libctx, src->propq,
+                                          src->engine)) == NULL)
+        return NULL;
+
     /* copy the parameters */
     if (src->group != NULL
         && (selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {
diff --git a/crypto/params.c b/crypto/params.c
index 50e900a406..d9743633b0 100644
--- a/crypto/params.c
+++ b/crypto/params.c
@@ -1128,11 +1128,13 @@ int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len)
      */
     size_t data_length = p->data_size;
 
+    if (ret == 0)
+        return 0;
     if (data_length >= max_len)
         data_length = OPENSSL_strnlen(p->data, data_length);
     if (data_length >= max_len)
         return 0;            /* No space for a terminating NUL byte */
-    ((char *)*val)[data_length] = '\0';
+    (*val)[data_length] = '\0';
 
     return ret;
 }
diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c
index 358ac6053a..6d5303ab9d 100644
--- a/test/evp_extra_test2.c
+++ b/test/evp_extra_test2.c
@@ -566,7 +566,7 @@ static int do_check_utf8_str(OSSL_PARAM params[], const char *key,
                              const char *expected)
 {
     OSSL_PARAM *p;
-    char *bufp = 0;
+    char *bufp = NULL;
     int ret;
 
     ret = TEST_ptr(p = OSSL_PARAM_locate(params, key))


More information about the openssl-commits mailing list