Skip to content

Commit

Permalink
openssl, do not free session if it was passed to Curl_ssl_addsessionid()
Browse files Browse the repository at this point in the history
  • Loading branch information
icing committed Apr 17, 2024
1 parent fef7aa1 commit 9d50c60
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/vtls/openssl.c
Expand Up @@ -2936,7 +2936,7 @@ ossl_set_ssl_version_min_max_legacy(ctx_option_t *ctx_options,
CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf,
struct Curl_easy *data,
const struct ssl_peer *peer,
SSL_SESSION *ssl_sessionid)
SSL_SESSION *session)
{
const struct ssl_config_data *config;
bool isproxy;
Expand All @@ -2950,30 +2950,30 @@ CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf,
config = Curl_ssl_cf_get_config(cf, data);
if(config->primary.sessionid) {
bool incache;
void *old_ssl_sessionid = NULL;
void *old_session = NULL;

Curl_ssl_sessionid_lock(data);
if(isproxy)
incache = FALSE;
else
incache = !(Curl_ssl_getsessionid(cf, data, peer,
&old_ssl_sessionid, NULL));
if(incache && (old_ssl_sessionid != ssl_sessionid)) {
&old_session, NULL));
if(incache && (old_session != session)) {
infof(data, "old SSL session ID is stale, removing");
Curl_ssl_delsessionid(data, old_ssl_sessionid);
Curl_ssl_delsessionid(data, old_session);
incache = FALSE;
}

if(!incache && !Curl_ssl_addsessionid(cf, data, peer, ssl_sessionid, 0,
ossl_session_free)) {
if(!incache) {
added = TRUE;
Curl_ssl_addsessionid(cf, data, peer, session, 0, ossl_session_free);
}
Curl_ssl_sessionid_unlock(data);
}

out:
if(!added)
ossl_session_free(ssl_sessionid, 0);
ossl_session_free(session, 0);
return CURLE_OK;
}

Expand Down

0 comments on commit 9d50c60

Please sign in to comment.