diff options
author | Michael Kaufmann <mail@michael-kaufmann.ch> | 2021-09-22 12:04:25 +0200 |
---|---|---|
committer | Michael Kaufmann <mail@michael-kaufmann.ch> | 2021-09-24 13:23:42 +0200 |
commit | 60738f398cdd66312bce6ce92a87f19e71feacf4 (patch) | |
tree | 998eba54603342b4d194d44a4709a6bbee9d973e /lib/vtls/schannel.c | |
parent | f4a3ae8ea8dd913ea8c9b5cced5a13c051318816 (diff) | |
download | curl-60738f398cdd66312bce6ce92a87f19e71feacf4.tar.gz |
vtls: Fix a memory leak if an SSL session cannot be added to the cache
On connection shutdown, a new TLS session ticket may arrive after the
SSL session cache has already been destructed. In this case, the new
SSL session cannot be added to the SSL session cache.
The callers of Curl_ssl_addsessionid() need to know whether the SSL
session has been added to the cache. If it has not been added, the
reference counter of the SSL session must not be incremented, or memory
used by the SSL session must be freed. This is now possible with the new
output parameter "added" of Curl_ssl_addsessionid().
Fixes #7683
Closes #7752
Diffstat (limited to 'lib/vtls/schannel.c')
-rw-r--r-- | lib/vtls/schannel.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 20c478533..ef3c919bb 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -1436,6 +1436,7 @@ schannel_connect_step3(struct Curl_easy *data, struct connectdata *conn, /* save the current session data for possible re-use */ if(SSL_SET_OPTION(primary.sessionid)) { bool incache; + bool added = FALSE; struct Curl_schannel_cred *old_cred = NULL; Curl_ssl_sessionid_lock(data); @@ -1453,13 +1454,13 @@ schannel_connect_step3(struct Curl_easy *data, struct connectdata *conn, if(!incache) { result = Curl_ssl_addsessionid(data, conn, isproxy, BACKEND->cred, sizeof(struct Curl_schannel_cred), - sockindex); + sockindex, &added); if(result) { Curl_ssl_sessionid_unlock(data); failf(data, "schannel: failed to store credential handle"); return result; } - else { + else if(added) { /* this cred session is now also referenced by sessionid cache */ BACKEND->cred->refcount++; DEBUGF(infof(data, |