mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-10 00:49:04 +08:00
Fix search for outdated entries in SSL session cache
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
c3f4a97b8f
commit
78196e366f
@ -137,9 +137,6 @@ static int ssl_cache_pick_writing_slot( mbedtls_ssl_cache_context *cache,
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
mbedtls_ssl_cache_entry *cur, *last;
|
mbedtls_ssl_cache_entry *cur, *last;
|
||||||
|
|
||||||
cur = cache->chain;
|
|
||||||
last = NULL;
|
|
||||||
|
|
||||||
/* Check 1: Is there already an entry with the given session ID?
|
/* Check 1: Is there already an entry with the given session ID?
|
||||||
*
|
*
|
||||||
* If yes, overwrite it.
|
* If yes, overwrite it.
|
||||||
@ -148,7 +145,8 @@ static int ssl_cache_pick_writing_slot( mbedtls_ssl_cache_context *cache,
|
|||||||
* at the end of this loop, and `last` will point to the last
|
* at the end of this loop, and `last` will point to the last
|
||||||
* entry, both of which will be used later. */
|
* entry, both of which will be used later. */
|
||||||
|
|
||||||
while( cur != NULL )
|
last = NULL;
|
||||||
|
for( cur = cache->chain; cur != NULL; cur = cur->next )
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if( session_id_len == cur->session_id_len &&
|
if( session_id_len == cur->session_id_len &&
|
||||||
@ -156,7 +154,7 @@ static int ssl_cache_pick_writing_slot( mbedtls_ssl_cache_context *cache,
|
|||||||
{
|
{
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
last = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check 2: Is there an outdated entry in the cache?
|
/* Check 2: Is there an outdated entry in the cache?
|
||||||
@ -167,7 +165,7 @@ static int ssl_cache_pick_writing_slot( mbedtls_ssl_cache_context *cache,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
while( cur != NULL )
|
for( cur = cache->chain; cur != NULL; cur = cur->next )
|
||||||
{
|
{
|
||||||
if( cache->timeout != 0 &&
|
if( cache->timeout != 0 &&
|
||||||
(int) ( t - cur->timestamp ) > cache->timeout )
|
(int) ( t - cur->timestamp ) > cache->timeout )
|
||||||
@ -180,9 +178,6 @@ static int ssl_cache_pick_writing_slot( mbedtls_ssl_cache_context *cache,
|
|||||||
oldest = cur->timestamp;
|
oldest = cur->timestamp;
|
||||||
old = cur;
|
old = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = cur;
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_HAVE_TIME */
|
#endif /* MBEDTLS_HAVE_TIME */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user