The branch master has been updated via f5e97b3702916e69873746108ac7c100a31d2241 (commit) via cd1981a0dc165ab6af5e2945beaaa9efe4484cee (commit) from 254217a4a0c9e64869495447a0e6bdc2323d4cd1 (commit)
- Log ----------------------------------------------------------------- commit f5e97b3702916e69873746108ac7c100a31d2241 Author: Matt Caswell <m...@openssl.org> Date: Mon Jan 10 14:46:46 2022 +0000 Ensure we test fetching encoder/decoder/store loader with a query string Although we had a test for fetching an encoder/decoder/store loader it did not use a query string. The issue highlighted by #17456 only occurs if a query string is used. Reviewed-by: Tomas Mraz <to...@openssl.org> Reviewed-by: Richard Levitte <levi...@openssl.org> Reviewed-by: Paul Dale <pa...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17459) commit cd1981a0dc165ab6af5e2945beaaa9efe4484cee Author: Matt Caswell <m...@openssl.org> Date: Mon Jan 10 14:45:16 2022 +0000 Fix Decoder, Encoder and Store loader fetching Attempting to fetch one of the above and providing a query string was failing with an internal assertion error. We must ensure that we give the provider when calling ossl_method_store_cache_set() Fixes #17456 Reviewed-by: Tomas Mraz <to...@openssl.org> Reviewed-by: Richard Levitte <levi...@openssl.org> Reviewed-by: Paul Dale <pa...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17459) ----------------------------------------------------------------------- Summary of changes: crypto/encode_decode/decoder_meth.c | 5 +++-- crypto/encode_decode/encoder_meth.c | 5 +++-- crypto/store/store_meth.c | 5 +++-- test/provfetchtest.c | 19 +++++++++++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c index 6d44437314..25407b8999 100644 --- a/crypto/encode_decode/decoder_meth.c +++ b/crypto/encode_decode/decoder_meth.c @@ -375,13 +375,14 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id, construct_decoder, destruct_decoder }; + OSSL_PROVIDER *prov = NULL; methdata->id = id; methdata->names = name; methdata->propquery = properties; methdata->flag_construct_error_occurred = 0; if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_DECODER, - NULL, 0 /* !force_cache */, + &prov, 0 /* !force_cache */, &mcm, methdata)) != NULL) { /* * If construction did create a method for us, we know that @@ -392,7 +393,7 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id, if (id == 0 && name != NULL) id = ossl_namemap_name2num(namemap, name); if (id != 0) - ossl_method_store_cache_set(store, NULL, id, properties, method, + ossl_method_store_cache_set(store, prov, id, properties, method, up_ref_decoder, free_decoder); } diff --git a/crypto/encode_decode/encoder_meth.c b/crypto/encode_decode/encoder_meth.c index 9c0214db6b..43eca755ac 100644 --- a/crypto/encode_decode/encoder_meth.c +++ b/crypto/encode_decode/encoder_meth.c @@ -385,13 +385,14 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata, int id, construct_encoder, destruct_encoder }; + OSSL_PROVIDER *prov = NULL; methdata->id = id; methdata->names = name; methdata->propquery = properties; methdata->flag_construct_error_occurred = 0; if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_ENCODER, - NULL, 0 /* !force_cache */, + &prov, 0 /* !force_cache */, &mcm, methdata)) != NULL) { /* * If construction did create a method for us, we know that @@ -401,7 +402,7 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata, int id, */ if (id == 0) id = ossl_namemap_name2num(namemap, name); - ossl_method_store_cache_set(store, NULL, id, properties, method, + ossl_method_store_cache_set(store, prov, id, properties, method, up_ref_encoder, free_encoder); } diff --git a/crypto/store/store_meth.c b/crypto/store/store_meth.c index e79ec871fd..10b56bc685 100644 --- a/crypto/store/store_meth.c +++ b/crypto/store/store_meth.c @@ -317,13 +317,14 @@ inner_loader_fetch(struct loader_data_st *methdata, int id, construct_loader, destruct_loader }; + OSSL_PROVIDER *prov = NULL; methdata->scheme_id = id; methdata->scheme = scheme; methdata->propquery = properties; methdata->flag_construct_error_occurred = 0; if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_STORE, - NULL, 0 /* !force_cache */, + &prov, 0 /* !force_cache */, &mcm, methdata)) != NULL) { /* * If construction did create a method for us, we know that there @@ -332,7 +333,7 @@ inner_loader_fetch(struct loader_data_st *methdata, int id, */ if (id == 0) id = ossl_namemap_name2num(namemap, scheme); - ossl_method_store_cache_set(store, NULL, id, properties, method, + ossl_method_store_cache_set(store, prov, id, properties, method, up_ref_loader, free_loader); } diff --git a/test/provfetchtest.c b/test/provfetchtest.c index b1f9d08c46..aae9b40057 100644 --- a/test/provfetchtest.c +++ b/test/provfetchtest.c @@ -225,6 +225,7 @@ static int dummy_provider_init(const OSSL_CORE_HANDLE *handle, * Test 1: Encoder * Test 2: Store loader * Test 3: EVP_RAND + * Test 4-7: As above, but additionally with a query string */ static int fetch_test(int tst) { @@ -236,6 +237,7 @@ static int fetch_test(int tst) OSSL_STORE_LOADER *loader = NULL; int testresult = 0; unsigned char buf[32]; + int query = tst > 3; if (!TEST_ptr(libctx)) goto err; @@ -246,24 +248,29 @@ static int fetch_test(int tst) || !TEST_ptr(dummyprov = OSSL_PROVIDER_load(libctx, "dummy-prov"))) goto err; - switch (tst) { + switch (tst % 4) { case 0: - decoder = OSSL_DECODER_fetch(libctx, "DUMMY", NULL); + decoder = OSSL_DECODER_fetch(libctx, "DUMMY", + query ? "provider=dummy" : NULL); if (!TEST_ptr(decoder)) goto err; break; case 1: - encoder = OSSL_ENCODER_fetch(libctx, "DUMMY", NULL); + encoder = OSSL_ENCODER_fetch(libctx, "DUMMY", + query ? "provider=dummy" : NULL); if (!TEST_ptr(encoder)) goto err; break; case 2: - loader = OSSL_STORE_LOADER_fetch(libctx, "DUMMY", NULL); + loader = OSSL_STORE_LOADER_fetch(libctx, "DUMMY", + query ? "provider=dummy" : NULL); if (!TEST_ptr(loader)) goto err; break; case 3: - if (!TEST_true(RAND_set_DRBG_type(libctx, "DUMMY", NULL, NULL, NULL)) + if (!TEST_true(RAND_set_DRBG_type(libctx, "DUMMY", + query ? "provider=dummy" : NULL, + NULL, NULL)) || !TEST_int_ge(RAND_bytes_ex(libctx, buf, sizeof(buf), 0), 1)) goto err; break; @@ -284,7 +291,7 @@ static int fetch_test(int tst) int setup_tests(void) { - ADD_ALL_TESTS(fetch_test, 4); + ADD_ALL_TESTS(fetch_test, 8); return 1; }