From: Shane Lontis Date: Thu, 10 Sep 2020 08:21:46 +0000 (+1000) Subject: Fix coverity issue: CID 1466482 - Resource leak in OSSL_STORE_SEARCH_by_key_fingerprint() X-Git-Tag: openssl-3.0.0-alpha7~293 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97f7a6d42e9d2f38969aff75b0d8f00d934ac8cf;p=thirdparty%2Fopenssl.git Fix coverity issue: CID 1466482 - Resource leak in OSSL_STORE_SEARCH_by_key_fingerprint() Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12847) --- diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index 8cf051818c2..0f686fb1191 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -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; } diff --git a/test/ossl_store_test.c b/test/ossl_store_test.c index 9b488279832..2ce7d518779 100644 --- a/test/ossl_store_test.c +++ b/test/ossl_store_test.c @@ -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; }