diff options
author | Bodo Möller <bodo@openssl.org> | 2012-10-05 20:50:11 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2012-10-05 20:50:11 +0000 |
commit | f11d0c7908b3124e2db72029e7e960294ca19b2e (patch) | |
tree | 53e75a416a0bfeeaba4410de11b90bb90ecee2fe /crypto/ecdh | |
parent | 323fa645593a1d2b753f25c9dd03a02ae887516b (diff) | |
download | openssl-f11d0c7908b3124e2db72029e7e960294ca19b2e.tar.gz |
Fix EC_KEY initialization race.
Submitted by: Adam Langley
Diffstat (limited to 'crypto/ecdh')
-rw-r--r-- | crypto/ecdh/ech_lib.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c index 4d8ea03d3d..75ff1da41d 100644 --- a/crypto/ecdh/ech_lib.c +++ b/crypto/ecdh/ech_lib.c @@ -210,8 +210,15 @@ ECDH_DATA *ecdh_check(EC_KEY *key) ecdh_data = (ECDH_DATA *)ecdh_data_new(); if (ecdh_data == NULL) return NULL; - EC_KEY_insert_key_method_data(key, (void *)ecdh_data, - ecdh_data_dup, ecdh_data_free, ecdh_data_free); + data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data, + ecdh_data_dup, ecdh_data_free, ecdh_data_free); + if (data != NULL) + { + /* Another thread raced us to install the key_method + * data and won. */ + ecdh_data_free(ecdh_data); + ecdh_data = (ECDH_DATA *)data; + } } else ecdh_data = (ECDH_DATA *)data; |