summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-11-08 22:10:18 +0000
committertb <>2024-11-08 22:10:18 +0000
commit7ae287b389f7b4b66ed89fa379b4d295cdf76231 (patch)
treeef679e196b3de7749f295dd1a29a612172a4d042 /src/lib
parent6b42101493f1f270e3e232e576ceb26a05cede5f (diff)
downloadopenbsd-7ae287b389f7b4b66ed89fa379b4d295cdf76231.tar.gz
openbsd-7ae287b389f7b4b66ed89fa379b4d295cdf76231.tar.bz2
openbsd-7ae287b389f7b4b66ed89fa379b4d295cdf76231.zip
Clean up EC_KEY_dup()
This calls init() with the default method, so EC_KEY_copy() gets a chance to call finish() if the source's method doesn't match. But no init() call is made in EC_KEY_copy(). Of course the source method's copy() needs to be able to cope. The great news is that ssh uses this. Sigh. ok beck jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/ec_key.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index 4f3f27dabd..1aef634349 100644
--- a/src/lib/libcrypto/ec/ec_key.c
+++ b/src/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_key.c,v 1.45 2024/11/08 22:03:29 tb Exp $ */ 1/* $OpenBSD: ec_key.c,v 1.46 2024/11/08 22:10:18 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -186,17 +186,22 @@ EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
186LCRYPTO_ALIAS(EC_KEY_copy); 186LCRYPTO_ALIAS(EC_KEY_copy);
187 187
188EC_KEY * 188EC_KEY *
189EC_KEY_dup(const EC_KEY *ec_key) 189EC_KEY_dup(const EC_KEY *in_ec_key)
190{ 190{
191 EC_KEY *ret; 191 EC_KEY *ec_key;
192 192
193 if ((ret = EC_KEY_new_method(NULL)) == NULL) 193 /* XXX - Pass NULL - so we're perhaps not running the right init()? */
194 return NULL; 194 if ((ec_key = EC_KEY_new_method(NULL)) == NULL)
195 if (EC_KEY_copy(ret, ec_key) == NULL) { 195 goto err;
196 EC_KEY_free(ret); 196 if (EC_KEY_copy(ec_key, in_ec_key) == NULL)
197 return NULL; 197 goto err;
198 } 198
199 return ret; 199 return ec_key;
200
201 err:
202 EC_KEY_free(ec_key);
203
204 return NULL;
200} 205}
201LCRYPTO_ALIAS(EC_KEY_dup); 206LCRYPTO_ALIAS(EC_KEY_dup);
202 207