Fix crash in xkey-provider in msvc builds
PATCH 1/1 Fix crash in xkey-provider in msvc builds
From: Selva Nair <[email protected]...>
The function signature for xkey_load_generic_key had function pointers defined as function types that seems to work in gcc but not in msvc.
Fix it by changing the function signatures to what was intended.
Also revert part of commit 627d1a3d28638... as that work- around should be no longer required.
Reported by: Lev Stipakov https://github.com/lstipakov
--- src/openvpn/xkey_common.h | 2 +- src/openvpn/xkey_helper.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
src/openvpn/xkey_common.h +1 -1
@@ -152,7 +152,7 @@ xkey_digest(const unsigned char *src, size_t srclen, unsigned char *buf,*/ EVP_PKEY *xkey_load_generic_key (OSSL_LIB_CTX *libctx,void *handle,EVP_PKEY *pubkey, -XKEY_EXTERNAL_SIGN_fn sign_op,XKEY_PRIVKEY_FREE_fn free_op); +XKEY_EXTERNAL_SIGN_fn *sign_op,XKEY_PRIVKEY_FREE_fn *free_op);extern OSSL_LIB_CTX *tls_libctx;/* Global */
src/openvpn/xkey_helper.c +3 -3
@@ -115,7 +115,7 @@ xkey_load_management_key(OSSL_LIB_CTX *libctx, EVP_PKEY *pubkey)*/ EVP_PKEY *xkey_load_generic_key (OSSL_LIB_CTX *libctx,void *handle,EVP_PKEY *pubkey, -XKEY_EXTERNAL_SIGN_fn sign_op,XKEY_PRIVKEY_FREE_fn free_op) +XKEY_EXTERNAL_SIGN_fn *sign_op,XKEY_PRIVKEY_FREE_fn *free_op) {EVP_PKEY *pkey =NULL ;const char *origin ="external" ;
@@ -125,8 +125,8 @@ xkey_load_generic_key(OSSL_LIB_CTX *libctx, void *handle, EVP_PKEY *pubkey, {"xkey-origin", OSSL_PARAM_UTF8_STRING, (char *) origin, 0, 0}, {"pubkey", OSSL_PARAM_OCTET_STRING, &pubkey, sizeof(pubkey), 0}, {"handle", OSSL_PARAM_OCTET_PTR, &handle, sizeof(handle), 0}, - {"sign_op", OSSL_PARAM_OCTET_PTR, (void **) &sign_op, sizeof(void *), 0}, - {"free_op", OSSL_PARAM_OCTET_PTR, (void **) &free_op, sizeof(void *), 0}, + {"sign_op", OSSL_PARAM_OCTET_PTR, (void **) &sign_op, sizeof(sign_op), 0}, + {"free_op", OSSL_PARAM_OCTET_PTR, (void **) &free_op, sizeof(free_op), 0}, {NULL, 0, NULL, 0, 0} }; msg(M_INFO, "%s: handle = %p sign_op = %p free_op = %p ", __FUNCTION__,
Signature · 1 line
2.30.2
Hi,
Any thoughts on this? Apart from the broken msvc builds that led to this, looks like the right thing to do, isn't it?
Selva
Quoted 74 lines · On Wed, Jul 6, 2022 at 11:52 PM <[email protected]...> wrote:
From: Selva Nair <[email protected]...>
The function signature for
xkey_load_generic_keyhad function pointers defined as function types that seems to work in gcc but not in msvc.Fix it by changing the function signatures to what was intended.
Also revert part of commit627d1a3d28638... as that work- around should be no longer required.Reported by: Lev Stipakov https://github.com/lstipakov
Signed-off-by Selva Nair <[email protected]...>--- src/openvpn/xkey_common.h | 2 +- src/openvpn/xkey_helper.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)src/openvpn/xkey_common.h +1
-1@@ -152,7 +152,7 @@ xkey_digest(const unsigned char *src, size_t srclen,unsigned char *buf, */ EVP_PKEY *xkey_load_generic_key (OSSL_LIB_CTX *libctx,void *handle,EVP_PKEY *pubkey, -XKEY_EXTERNAL_SIGN_fn sign_op,XKEY_PRIVKEY_FREE_fn free_op ); + XKEY_EXTERNAL_SIGN_fn *sign_op,
XKEY_PRIVKEY_FREE_fn*free_op);extern
OSSL_LIB_CTX*tls_libctx; /* Global */src/openvpn/xkey_helper.c +1
-1@@ -115,7 +115,7 @@ xkey_load_management_key(OSSL_LIB_CTX *libctx,EVP_PKEY *pubkey) */ EVP_PKEY *xkey_load_generic_key (OSSL_LIB_CTX *libctx,void *handle,EVP_PKEY *pubkey, -XKEY_EXTERNAL_SIGN_fn sign_op,XKEY_PRIVKEY_FREE_fn free_op ) + XKEY_EXTERNAL_SIGN_fn *sign_op,
XKEY_PRIVKEY_FREE_fn*free_op){ EVP_PKEY *pkey = NULL; const char *origin = "external";src/openvpn/xkey_helper.c +1
-2@@ -125,8 +125,8 @@ xkey_load_generic_key(OSSL_LIB_CTX *libctx, void *handle,EVP_PKEY *pubkey, {"xkey-origin", OSSL_PARAM_UTF8_STRING, (char *) origin, 0, 0}, {"pubkey", OSSL_PARAM_OCTET_STRING, &pubkey, sizeof(pubkey), 0}, {"handle", OSSL_PARAM_OCTET_PTR, &handle, sizeof(handle), 0}, - {"sign_op", OSSL_PARAM_OCTET_PTR, (void **) &sign_op, sizeof(void *), 0}, - {"free_op", OSSL_PARAM_OCTET_PTR, (void **) &free_op, sizeof(void *), 0}, + {"sign_op", OSSL_PARAM_OCTET_PTR, (void **) &sign_op,
sizeof(sign_op), 0},
+ {"free_op",OSSL_PARAM_OCTET_PTR, (void **)&free_op,sizeof(free_op), 0},{NULL, 0, NULL, 0, 0} }; msg(M_INFO, "%s: handle = %p sign_op = %p free_op = %p ",
__FUNCTION__,
--
2.30.2
Am 07.07.22 um 05:51 schrieb [email protected]...:
Quoted 6 lines
From: Selva Nair <[email protected]...>
The function signature for
xkey_load_generic_keyhad function pointers defined as function types that seems to work in gcc but not in msvc.
Quoted 7 lines
Fix it by changing the function signatures to what was intended.
Also revert part of commit627d1a3d28638... as that work- around should be no longer required.Reported by: Lev Stipakov https://github.com/lstipakov
I am surprised that this commit is not a noop but it is "more" correct this. So without any idea if this actually fixes Windows or not, I approve this commit on the basis of a cosmetic fix that is actually right.
Arne
Taking the agreement from Arne as formal ACK (checked on IRC).
I'm not sure I grok all the details of this, but I can attest that unit_tests/test_provider still works (on a 3.0.x build), and that calls the "xkey_load_generic_key()" function being modified here. So, this is good. Lev promised to verify MSVC builds early next week.
Your patch has been applied to the master branch.
commit 2b2e4d0ad5c3a309af8425be8e6e605975fb2a43
Author: Selva Nair Date: Wed Jul 6 23:51:51 2022 -0400
Fix crash in xkey-provider in msvc builds
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg24664.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering