diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-11-24 18:48:10 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-29 08:21:34 +0100 |
commit | 92a25e24e6ec9735dea9ec645502cb075a5f8d24 (patch) | |
tree | 480f7c3a97fd27f48bc2b85a407213daff15dc3a /test | |
parent | Fix accumulated index comments in felem_inv for p521 (diff) | |
download | openssl-92a25e24e6ec9735dea9ec645502cb075a5f8d24.tar.xz openssl-92a25e24e6ec9735dea9ec645502cb075a5f8d24.zip |
Fix occasional assertion failure when storing properties
Fixes #18631
The store lock does not prevent concurrent access to the
property cache, because there are multiple stores.
We drop the newly created entry and use the exisiting one
if there is one already.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19762)
Diffstat (limited to 'test')
-rw-r--r-- | test/property_test.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/test/property_test.c b/test/property_test.c index 14b891c3a0..3b97863803 100644 --- a/test/property_test.c +++ b/test/property_test.c @@ -284,19 +284,42 @@ static int test_property_merge(int n) static int test_property_defn_cache(void) { OSSL_METHOD_STORE *store; - OSSL_PROPERTY_LIST *red, *blue; - int r = 0; + OSSL_PROPERTY_LIST *red = NULL, *blue = NULL, *blue2 = NULL; + int r; - if (TEST_ptr(store = ossl_method_store_new(NULL)) + r = TEST_ptr(store = ossl_method_store_new(NULL)) && add_property_names("red", "blue", NULL) && TEST_ptr(red = ossl_parse_property(NULL, "red")) && TEST_ptr(blue = ossl_parse_property(NULL, "blue")) && TEST_ptr_ne(red, blue) - && TEST_true(ossl_prop_defn_set(NULL, "red", red)) - && TEST_true(ossl_prop_defn_set(NULL, "blue", blue)) - && TEST_ptr_eq(ossl_prop_defn_get(NULL, "red"), red) - && TEST_ptr_eq(ossl_prop_defn_get(NULL, "blue"), blue)) - r = 1; + && TEST_true(ossl_prop_defn_set(NULL, "red", &red)); + + if (!r) { + ossl_property_free(red); + red = NULL; + ossl_property_free(blue); + blue = NULL; + } + + r = r && TEST_true(ossl_prop_defn_set(NULL, "blue", &blue)); + if (!r) { + ossl_property_free(blue); + blue = NULL; + } + + r = r && TEST_ptr_eq(ossl_prop_defn_get(NULL, "red"), red) + && TEST_ptr_eq(ossl_prop_defn_get(NULL, "blue"), blue) + && TEST_ptr(blue2 = ossl_parse_property(NULL, "blue")) + && TEST_ptr_ne(blue2, blue) + && TEST_true(ossl_prop_defn_set(NULL, "blue", &blue2)); + if (!r) { + ossl_property_free(blue2); + blue2 = NULL; + } + + r = r && TEST_ptr_eq(blue2, blue) + && TEST_ptr_eq(ossl_prop_defn_get(NULL, "blue"), blue); + ossl_method_store_free(store); return r; } |