]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Coverity fixes
authorShane Lontis <shane.lontis@oracle.com>
Tue, 4 Jun 2019 01:32:58 +0000 (11:32 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Wed, 5 Jun 2019 23:34:17 +0000 (09:34 +1000)
covID 1445689 Resource leak (in error path)
covID 1445318 Resource leak (in test - minor)
covID 1443705 Unchecked return value (Needed if CRYPTO_atomic_add() was used)
covID 1443691 Resource leak (in app - minor)

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9071)

apps/verify.c
crypto/provider_core.c
ssl/tls13_enc.c
test/enginetest.c

index 3767972a5e7a0f611e2d57febfd8511c066fa0ab..fd407646f519ab9cd50273dfdb6deb4eba5836e9 100644 (file)
@@ -169,11 +169,20 @@ int verify_main(int argc, char **argv)
             v_verbose = 1;
             break;
         case OPT_SM2ID:
-            /* we assume the input is not a hex string */
+            if (sm2_id != NULL) {
+                BIO_printf(bio_err,
+                           "Use one of the options 'sm2-hex-id' or 'sm2-id' \n");
+                goto end;
+            }
             sm2_id = (unsigned char *)opt_arg();
             sm2_idlen = strlen((const char *)sm2_id);
             break;
         case OPT_SM2HEXID:
+            if (sm2_id != NULL) {
+                BIO_printf(bio_err,
+                           "Use one of the options 'sm2-hex-id' or 'sm2-id' \n");
+                goto end;
+            }
             /* try to parse the input as hex string first */
             sm2_free = 1;
             sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen);
index 837f4b5daf115232a377bc90a199a8f7925c0e92..bcf6aa9eb1cc1c7da1e44eefa4db6d7790c0155c 100644 (file)
@@ -194,7 +194,8 @@ int ossl_provider_upref(OSSL_PROVIDER *prov)
 {
     int ref = 0;
 
-    CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock);
+    if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0)
+        return 0;
     return ref;
 }
 
index b0fc4b296d1c0595fd0696a840875bb65364679d..9bc34c1b8544204fd211334986e0534dfb50b2c8 100644 (file)
@@ -170,6 +170,7 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md,
     if (!ossl_assert(mdleni >= 0)) {
         SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_GENERATE_SECRET,
                  ERR_R_INTERNAL_ERROR);
+        EVP_KDF_CTX_free(kctx);
         return 0;
     }
     mdlen = (size_t)mdleni;
index 4836cbe92fd8ef18ef1d6501867f927a8f08cd80..b4d117efa2a64f8686f5e5764381f84bbe17bf96 100644 (file)
@@ -279,7 +279,7 @@ static int test_redirect(void)
      * Try setting test key engine. Both should fail because the
      * engine has no public key methods.
      */
-    if (!TEST_ptr_null(EVP_PKEY_CTX_new(pkey, e))
+    if (!TEST_ptr_null(ctx = EVP_PKEY_CTX_new(pkey, e))
             || !TEST_int_le(EVP_PKEY_set1_engine(pkey, e), 0))
         goto err;