From: Stefan Eissing Date: Mon, 5 Feb 2024 16:29:24 +0000 (+0100) Subject: openssl-quic: check on Windows that socket conv to int is possible X-Git-Tag: curl-8_7_0~226 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6825df334def106f735ce7e0c1a2ea87bddffb0;p=thirdparty%2Fcurl.git openssl-quic: check on Windows that socket conv to int is possible Fixes #12861 Closes #12865 --- 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;