]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix coverity issue: CID 1466482 - Resource leak in OSSL_STORE_SEARCH_by_key_fingerprint()
authorShane Lontis <shane.lontis@oracle.com>
Thu, 10 Sep 2020 08:21:46 +0000 (18:21 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Sat, 12 Sep 2020 05:57:24 +0000 (15:57 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12847)

crypto/store/store_lib.c
test/ossl_store_test.c

index 8cf051818c25f1f87b1a53f9ce93937563166ea9..0f686fb1191c209b75d3b0618aa61e8ed79694c8 100644 (file)
@@ -850,6 +850,7 @@ OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest,
                        OSSL_STORE_R_FINGERPRINT_SIZE_DOES_NOT_MATCH_DIGEST,
                        "%s size is %d, fingerprint size is %zu",
                        EVP_MD_name(digest), EVP_MD_size(digest), len);
+        OPENSSL_free(search);
         return NULL;
     }
 
index 9b48827983277da064d8a447fc77c8e6226c189a..2ce7d518779133767ddbba1bb48db59690a2023c 100644 (file)
@@ -40,6 +40,17 @@ static int test_store_open(void)
     return ret;
 }
 
+static int test_store_search_by_key_fingerprint_fail(void)
+{
+    int ret;
+    OSSL_STORE_SEARCH *search = NULL;
+
+    ret = TEST_ptr_null(search = OSSL_STORE_SEARCH_by_key_fingerprint(
+                                     EVP_sha256(), NULL, 0));
+    OSSL_STORE_SEARCH_free(search);
+    return ret;
+}
+
 const OPTIONS *test_get_options(void)
 {
     static const OPTIONS test_options[] = {
@@ -68,5 +79,6 @@ int setup_tests(void)
     }
 
     ADD_TEST(test_store_open);
+    ADD_TEST(test_store_search_by_key_fingerprint_fail);
     return 1;
 }