From 07d3f305ea24da68aec66c7e4be39317f6ea7dae Mon Sep 17 00:00:00 2001 From: op <> Date: Mon, 26 Aug 2024 22:01:28 +0000 Subject: replace atoi(3) usage with strtonum(3); ok/tweaks tb@ --- src/lib/libcrypto/ec/ec_pmeth.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/ec') diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c index 16fc07642a..d422765b00 100644 --- a/src/lib/libcrypto/ec/ec_pmeth.c +++ b/src/lib/libcrypto/ec/ec_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_pmeth.c,v 1.21 2023/12/28 22:12:37 tb Exp $ */ +/* $OpenBSD: ec_pmeth.c,v 1.22 2024/08/26 22:01:28 op Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -57,6 +57,7 @@ */ #include +#include #include #include @@ -445,10 +446,15 @@ pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) } return EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md); } else if (strcmp(type, "ecdh_cofactor_mode") == 0) { - int co_mode; - co_mode = atoi(value); - return EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, co_mode); + int cofactor_mode; + const char *errstr; + + cofactor_mode = strtonum(value, -1, 1, &errstr); + if (errstr != NULL) + return -2; + return EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, cofactor_mode); } + return -2; } -- cgit v1.2.3-55-g6feb