Skip to content

Commit d6825df

Browse files
icingbagder
authored andcommitted
openssl-quic: check on Windows that socket conv to int is possible
Fixes #12861 Closes #12865
1 parent 75d79a4 commit d6825df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/vquic/curl_osslq.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,20 @@ static CURLcode cf_osslq_ctx_start(struct Curl_cfilter *cf,
10781078
goto out;
10791079
}
10801080

1081+
/* Type conversions, see #12861: OpenSSL wants an `int`, but on 64-bit
1082+
* Win32 systems, Microsoft defines SOCKET as `unsigned long long`.
1083+
*/
1084+
#if defined(_WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H)
1085+
if(ctx->q.sockfd > INT_MAX) {
1086+
failf(data, "windows socket identifier larger than MAX_INT, "
1087+
"unable to set in OpenSSL dgram API.");
1088+
result = CURLE_QUIC_CONNECT_ERROR;
1089+
goto out;
1090+
}
1091+
bio = BIO_new_dgram((int)ctx->q.sockfd, BIO_NOCLOSE);
1092+
#else
1093+
bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE);
1094+
#endif
10811095
bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE);
10821096
if(!bio) {
10831097
result = CURLE_OUT_OF_MEMORY;

0 commit comments

Comments
 (0)