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
diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c
index 6089ca8..fdd7348 100644
--- a/library/ssl_ciphersuites.c
+++ b/library/ssl_ciphersuites.c
@@ -844,14 +844,12 @@
size_t i;
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++ )
{
if( ssl_ciphersuite_from_id( p[i] ) != NULL )
*(q++) = p[i];
}
+ *q = 0;
supported_init = 1;
}