]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openssl-quic: check on Windows that socket conv to int is possible
authorStefan Eissing <stefan@eissing.org>
Mon, 5 Feb 2024 16:29:24 +0000 (17:29 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 5 Feb 2024 22:45:01 +0000 (23:45 +0100)
Fixes #12861
Closes #12865

lib/vquic/curl_osslq.c

index c499a004bf5204268e817f0cc13f395bb04cc0b1..9766feb2114a9ec11ad435fbe64745a0fef9b09b 100644 (file)
@@ -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;