diff options
author | Bodo Möller <bodo@openssl.org> | 2012-10-05 20:50:38 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2012-10-05 20:50:38 +0000 |
commit | b626f0396c308aa10eb19862ebe2afdd6e855b29 (patch) | |
tree | 3a009ffca6b2bc358effe62a891a7d8255219d1f /crypto/ecdsa | |
parent | 9d2006d8ed733522014035ec0514e23a312083e8 (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 e477da430b..814a6bf404 100644 --- a/crypto/ecdsa/ecs_lib.c +++ b/crypto/ecdsa/ecs_lib.c @@ -200,8 +200,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; |