vtls_scache: check reentrancy

Track lock status of session cache, add DEBUGASSERT()s for proper
calling sequences. Add check of lock status.

Use lock status check to prevent reentry of import/export calls.
Deny such calls with CURLE_RECURSIVE_API_CALL.

Closes #21383
This commit is contained in:
Stefan Eissing 2026-04-20 10:21:43 +02:00 committed by Daniel Stenberg
parent 85e825770a
commit 5448495cfd
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 29 additions and 9 deletions

View file

@ -1339,6 +1339,8 @@ CURLcode curl_easy_ssls_import(CURL *curl, const char *session_key,
struct Curl_easy *data = curl;
if(!GOOD_EASY_HANDLE(data))
return CURLE_BAD_FUNCTION_ARGUMENT;
if(Curl_is_in_callback(data) || Curl_ssl_scache_is_locked(data))
return CURLE_RECURSIVE_API_CALL;
return Curl_ssl_session_import(data, session_key,
shmac, shmac_len, sdata, sdata_len);
#else
@ -1360,6 +1362,8 @@ CURLcode curl_easy_ssls_export(CURL *curl,
struct Curl_easy *data = curl;
if(!GOOD_EASY_HANDLE(data))
return CURLE_BAD_FUNCTION_ARGUMENT;
if(Curl_is_in_callback(data) || Curl_ssl_scache_is_locked(data))
return CURLE_RECURSIVE_API_CALL;
return Curl_ssl_session_export(data, export_fn, userptr);
#else
(void)curl;