Skip to content

Commit 8b9e138

Browse files
authored
Merge pull request #6383 from philljj/zd16072
Fix session ticket leak in wolfSSL_Cleanup
2 parents 8f4524e + 9d05a4f commit 8b9e138

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/ssl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14356,12 +14356,9 @@ int wolfSSL_Cleanup(void)
1435614356
{
1435714357
int ret = WOLFSSL_SUCCESS; /* Only the first error will be returned */
1435814358
int release = 0;
14359-
#if !defined(NO_SESSION_CACHE) && (defined(ENABLE_SESSION_CACHE_ROW_LOCK) || \
14360-
defined(SESSION_CACHE_DYNAMIC_MEM))
14359+
#if !defined(NO_SESSION_CACHE)
1436114360
int i;
14362-
#ifdef SESSION_CACHE_DYNAMIC_MEM
1436314361
int j;
14364-
#endif
1436514362
#endif
1436614363

1436714364
WOLFSSL_ENTER("wolfSSL_Cleanup");
@@ -14406,17 +14403,20 @@ int wolfSSL_Cleanup(void)
1440614403
}
1440714404
session_lock_valid = 0;
1440814405
#endif
14409-
#ifdef SESSION_CACHE_DYNAMIC_MEM
1441014406
for (i = 0; i < SESSION_ROWS; i++) {
1441114407
for (j = 0; j < SESSIONS_PER_ROW; j++) {
14408+
#ifdef SESSION_CACHE_DYNAMIC_MEM
1441214409
if (SessionCache[i].Sessions[j]) {
14410+
EvictSessionFromCache(SessionCache[i].Sessions[j]);
1441314411
XFREE(SessionCache[i].Sessions[j], SessionCache[i].heap,
1441414412
DYNAMIC_TYPE_SESSION);
1441514413
SessionCache[i].Sessions[j] = NULL;
1441614414
}
14415+
#else
14416+
EvictSessionFromCache(&SessionCache[i].Sessions[j]);
14417+
#endif
1441714418
}
1441814419
}
14419-
#endif
1442014420
#ifndef NO_CLIENT_CACHE
1442114421
if ((clisession_mutex_valid == 1) &&
1442214422
(wc_FreeMutex(&clisession_mutex) != 0)) {
@@ -21457,8 +21457,8 @@ static int wolfSSL_DupSessionEx(const WOLFSSL_SESSION* input,
2145721457
* the static buffer. */
2145821458
if (ticBuff != NULL) {
2145921459
if (ticLenAlloc >= input->ticketLen) {
21460-
output->ticket = output->staticTicket;
21461-
output->ticketLenAlloc = 0;
21460+
output->ticket = ticBuff;
21461+
output->ticketLenAlloc = ticLenAlloc;
2146221462
}
2146321463
else {
2146421464
WOLFSSL_MSG("ticket dynamic buffer too small but we are "

0 commit comments

Comments
 (0)