]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix coverity CID #1466377 - resource leak due to early return in ec_get_params().
authorShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 01:32:48 +0000 (11:32 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Sat, 5 Sep 2020 05:41:30 +0000 (15:41 +1000)
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12708)

providers/implementations/keymgmt/ec_kmgmt.c

index cb5e2291da52c0b9b647b55e5b723311d6543246..05b5fdd969c7679e33668fc186b3c22902369b10 100644 (file)
@@ -526,10 +526,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 +565,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 +580,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),