mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 23:25:44 +01:00
Fix possible race in ssl_list_ciphersuites()
Thread A: executing for loop of ssl_list_ciphersuites() Thread B: call ssl_list_cipher_suites(), see init == 0 Thread A: return, start using the result Thread B: memset(0) on the list used by thread A
This commit is contained in:
parent
055ef61658
commit
bc4b7f08ba
@ -844,14 +844,12 @@ const int *ssl_list_ciphersuites( void )
|
|||||||
size_t i;
|
size_t i;
|
||||||
size_t max = sizeof(supported_ciphersuites) / sizeof(int);
|
size_t max = sizeof(supported_ciphersuites) / sizeof(int);
|
||||||
|
|
||||||
memset( supported_ciphersuites, 0x00, sizeof(supported_ciphersuites) );
|
|
||||||
|
|
||||||
/* Leave room for a final 0 */
|
|
||||||
for( i = 0; i < max - 1 && p[i] != 0; i++ )
|
for( i = 0; i < max - 1 && p[i] != 0; i++ )
|
||||||
{
|
{
|
||||||
if( ssl_ciphersuite_from_id( p[i] ) != NULL )
|
if( ssl_ciphersuite_from_id( p[i] ) != NULL )
|
||||||
*(q++) = p[i];
|
*(q++) = p[i];
|
||||||
}
|
}
|
||||||
|
*q = 0;
|
||||||
|
|
||||||
supported_init = 1;
|
supported_init = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user