diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-06-28 16:41:17 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-06-29 14:18:15 +0200 |
commit | 4aed7a192332cb6a975f135b256c193034332677 (patch) | |
tree | 04179e9841cab79ca23e197a8b44f6863cdcea3b /lib/vtls | |
parent | b5a434f7f0ee4d64857f8592eced5b9007d83620 (diff) | |
download | curl-4aed7a192332cb6a975f135b256c193034332677.tar.gz |
openssl: avoid static variable for seed flag
Avoid the race condition risk by instead storing the "seeded" flag in
the multi handle. Modern OpenSSL versions handle the seeding itself so
doing the seeding once per multi-handle instead of once per process is
less of an issue.
Reported-by: Gerrit Renker
Fixes #7296
Closes #7306
Diffstat (limited to 'lib/vtls')
-rw-r--r-- | lib/vtls/openssl.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index e4aa26ac1..52dbf5f3e 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -435,17 +435,16 @@ static bool rand_enough(void) static CURLcode ossl_seed(struct Curl_easy *data) { - /* we have the "SSL is seeded" boolean static to prevent multiple - time-consuming seedings in vain */ - static bool ssl_seeded = FALSE; char fname[256]; - if(ssl_seeded) + /* This might get called before it has been added to a multi handle */ + if(data->multi && data->multi->ssl_seeded) return CURLE_OK; if(rand_enough()) { /* OpenSSL 1.1.0+ will return here */ - ssl_seeded = TRUE; + if(data->multi) + data->multi->ssl_seeded = TRUE; return CURLE_OK; } |