From: Richard Levitte Date: Fri, 27 Oct 2017 20:42:04 +0000 (+0200) Subject: EVP_PKEY_asn1_add0(): Check that this method isn't already registered X-Git-Tag: OpenSSL_1_1_1-pre1~498 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=d85722d31ac9ff0dc54c06cdc8d125acf56ca27a EVP_PKEY_asn1_add0(): Check that this method isn't already registered No two public key ASN.1 methods with the same pkey_id can be registered at the same time. Reviewed-by: Bernd Edlinger (Merged from https://github.com/openssl/openssl/pull/4596) --- diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index 5f523b2969..87a3eba14a 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -137,6 +137,11 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth) { + if (pkey_asn1_find(ameth->pkey_id) != NULL) { + EVPerr(EVP_F_EVP_PKEY_ASN1_ADD0, + EVP_R_PKEY_ASN1_METHOD_ALREADY_REGISTERED); + return 0; + } if (app_methods == NULL) { app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp); if (app_methods == NULL)