From d6825df334def106f735ce7e0c1a2ea87bddffb0 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 5 Feb 2024 17:29:24 +0100 Subject: [PATCH] openssl-quic: check on Windows that socket conv to int is possible Fixes #12861 Closes #12865 --- lib/vquic/curl_osslq.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index c499a004bf..9766feb211 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1078,6 +1078,20 @@ static CURLcode cf_osslq_ctx_start(struct Curl_cfilter *cf, goto out; } + /* Type conversions, see #12861: OpenSSL wants an `int`, but on 64-bit + * Win32 systems, Microsoft defines SOCKET as `unsigned long long`. + */ +#if defined(_WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H) + if(ctx->q.sockfd > INT_MAX) { + failf(data, "windows socket identifier larger than MAX_INT, " + "unable to set in OpenSSL dgram API."); + result = CURLE_QUIC_CONNECT_ERROR; + goto out; + } + bio = BIO_new_dgram((int)ctx->q.sockfd, BIO_NOCLOSE); +#else + bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE); +#endif bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE); if(!bio) { result = CURLE_OUT_OF_MEMORY; -- 2.47.3