mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 19:24:37 +00:00
Fix a failure where fetches can return NULL in multi-threaded code
When a fetch is attempted simultaneously from multiple threads then both threads can attempt to construct the method. However only one of those will get added to the global evp method store. The one that "lost" the race to add the method to the global evp method store ended up with the fetch call returning NULL, instead of returning the method that was already available. Fixes #13682 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13660)
This commit is contained in:
parent
7dd2cb5693
commit
b11ba50fd9
@ -128,6 +128,16 @@ void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
|
|||||||
&cbdata);
|
&cbdata);
|
||||||
|
|
||||||
method = mcm->get(libctx, cbdata.store, mcm_data);
|
method = mcm->get(libctx, cbdata.store, mcm_data);
|
||||||
|
if (method == NULL) {
|
||||||
|
/*
|
||||||
|
* If we get here then we did not construct the method that we
|
||||||
|
* attempted to construct. It's possible that another thread got
|
||||||
|
* there first and so we skipped construction (pre-condition
|
||||||
|
* failed). We check the global store again to see if it has
|
||||||
|
* appeared by now.
|
||||||
|
*/
|
||||||
|
method = mcm->get(libctx, NULL, mcm_data);
|
||||||
|
}
|
||||||
mcm->dealloc_tmp_store(cbdata.store);
|
mcm->dealloc_tmp_store(cbdata.store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user