diff options
author | Bodo Möller <bodo@openssl.org> | 2012-10-05 20:51:47 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2012-10-05 20:51:47 +0000 |
commit | 75f0bc4f44f34450892a243e3747a6d3214925ed (patch) | |
tree | 88e4d7127aaf7c79b4b4bd5d6ed68dabc711a1f9 /crypto/ecdsa | |
parent | 71a2440ee59567edea2cf14c000f3ca9e933953c (diff) |
Fix EC_KEY initialization race.
Submitted by: Adam Langley
Diffstat (limited to 'crypto/ecdsa')
-rw-r--r-- | crypto/ecdsa/ecs_lib.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c index 2ebae3aa27..81082c9727 100644 --- a/crypto/ecdsa/ecs_lib.c +++ b/crypto/ecdsa/ecs_lib.c @@ -188,8 +188,15 @@ ECDSA_DATA *ecdsa_check(EC_KEY *key) ecdsa_data = (ECDSA_DATA *)ecdsa_data_new(); if (ecdsa_data == NULL) return NULL; - EC_KEY_insert_key_method_data(key, (void *)ecdsa_data, - ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); + data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data, + ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); + if (data != NULL) + { + /* Another thread raced us to install the key_method + * data and won. */ + ecdsa_data_free(ecdsa_data); + ecdsa_data = (ECDSA_DATA *)data; + } } else ecdsa_data = (ECDSA_DATA *)data; |