[openssl-dev] [openssl.org #3921] [PATCH] Fix const-correctness issues of new ECDSA_METHOD api

Dr. Matthias St. Pierre via RT rt at openssl.org
Mon Jun 22 20:07:43 UTC 2015


- The function ECDSA_METHOD_new() acts like a copy constructor, but unfortunately
  its argument is not declared const. This leads to compiler errors when it is
  used as follows:

    ECDSA_METHOD * method = ECDSA_METHOD_new(ECDSA_OpenSSL());

- The ECDSA_METHOD_set_name() should take a 'const char *' instead of a 'char *',
  because that's the type of the ecdsa_method 'name' member.
---
 crypto/ecdsa/ecdsa.h   | 4 ++--
 crypto/ecdsa/ecs_lib.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/crypto/ecdsa/ecdsa.h b/crypto/ecdsa/ecdsa.h
index c4016ac..d31cebc 100644
--- a/crypto/ecdsa/ecdsa.h
+++ b/crypto/ecdsa/ecdsa.h
@@ -233,7 +233,7 @@ void *ECDSA_get_ex_data(EC_KEY *d, int idx);
  *  \return pointer to a ECDSA_METHOD structure or NULL if an error occurred
  */
 
-ECDSA_METHOD *ECDSA_METHOD_new(ECDSA_METHOD *ecdsa_method);
+ECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_method);
 
 /** frees a ECDSA_METHOD structure
  *  \param  ecdsa_method  pointer to the ECDSA_METHOD structure
@@ -295,7 +295,7 @@ void ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags);
  *   \param  flags flags value to set
  */
 
-void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name);
+void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, const char *name);
 
 /**  Set the name field in the ECDSA_METHOD
  *   \param  ecdsa_method  pointer to existing ECDSA_METHOD
diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c
index 1c02310..05dab09 100644
--- a/crypto/ecdsa/ecs_lib.c
+++ b/crypto/ecdsa/ecs_lib.c
@@ -276,7 +276,7 @@ void *ECDSA_get_ex_data(EC_KEY *d, int idx)
     return (CRYPTO_get_ex_data(&ecdsa->ex_data, idx));
 }
 
-ECDSA_METHOD *ECDSA_METHOD_new(ECDSA_METHOD *ecdsa_meth)
+ECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_meth)
 {
     ECDSA_METHOD *ret;
 
@@ -332,7 +332,7 @@ void ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags)
     ecdsa_method->flags = flags | ECDSA_METHOD_FLAG_ALLOCATED;
 }
 
-void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name)
+void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, const char *name)
 {
     ecdsa_method->name = name;
 }
-- 
2.3.6

_______________________________________________
openssl-bugs-mod mailing list
openssl-bugs-mod at openssl.org
https://mta.openssl.org/mailman/listinfo/openssl-bugs-mod



More information about the openssl-dev mailing list