[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Mon Sep 10 10:15:36 UTC 2018


The branch master has been updated
       via  35db366cf453427c855bea8ca097618a8a8d7ff0 (commit)
      from  427e91d928ce7a1c583e4bba761cb17a85ac95b4 (commit)


- Log -----------------------------------------------------------------
commit 35db366cf453427c855bea8ca097618a8a8d7ff0
Author: Dr. Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
Date:   Mon Sep 10 00:20:12 2018 +0200

    test/evp_extra_test.c: fix null pointer dereference
    
    It's actually not a real issue but caused by the absence of the default case
    which does not occur in reality but which makes coverity see a code path where
    pkey remains unassigned.
    
    Reported by Coverity Scan (CID 1423323)
    [extended tests]
    
    Reviewed-by: Nicola Tuveri <nic.tuv at gmail.com>
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/7158)

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

Summary of changes:
 test/evp_extra_test.c | 43 ++++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index f0b0040..7b847ee 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -855,27 +855,32 @@ static int test_EVP_PKEY_check(int i)
 
     p = input;
 
-    if (type == 0 &&
-            (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len))
-             || !TEST_ptr_eq(p, input + input_len)
-             || !TEST_int_eq(EVP_PKEY_id(pkey), expected_id)))
-        goto done;
-
+    switch (type) {
+    case 0:
+        if (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len))
+            || !TEST_ptr_eq(p, input + input_len)
+            || !TEST_int_eq(EVP_PKEY_id(pkey), expected_id))
+            goto done;
+        break;
 #ifndef OPENSSL_NO_EC
-    if (type == 1 &&
-            (!TEST_ptr(pubkey = BIO_new_mem_buf(input, input_len))
-             || !TEST_ptr(eckey = d2i_EC_PUBKEY_bio(pubkey, NULL))
-             || !TEST_ptr(pkey = EVP_PKEY_new())
-             || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey))))
-        goto done;
-
-    if (type == 2 &&
-            (!TEST_ptr(eckey = d2i_ECParameters(NULL, &p, input_len))
-             || !TEST_ptr_eq(p, input + input_len)
-             || !TEST_ptr(pkey = EVP_PKEY_new())
-             || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey))))
-        goto done;
+    case 1:
+        if (!TEST_ptr(pubkey = BIO_new_mem_buf(input, input_len))
+            || !TEST_ptr(eckey = d2i_EC_PUBKEY_bio(pubkey, NULL))
+            || !TEST_ptr(pkey = EVP_PKEY_new())
+            || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))
+            goto done;
+        break;
+    case 2:
+        if (!TEST_ptr(eckey = d2i_ECParameters(NULL, &p, input_len))
+            || !TEST_ptr_eq(p, input + input_len)
+            || !TEST_ptr(pkey = EVP_PKEY_new())
+            || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))
+            goto done;
+        break;
 #endif
+    default:
+        return 0;
+    }
 
     if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL)))
         goto done;


More information about the openssl-commits mailing list