]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
schannel: guard ALPN init code to ALPN builds
authorViktor Szakats <commit@vsz.me>
Fri, 21 Feb 2025 12:00:27 +0000 (13:00 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 21 Feb 2025 12:17:56 +0000 (13:17 +0100)
To avoid unnecessary init work with toolchains not supporting ALPN.

Follow-up to 7fd15b4a827f08db153265aa45f755256bc251f3 #16393
Closes #16420

lib/vtls/schannel.c

index 06d1a5e4ec9f13c7e768e3adf6053112c9ccd7b4..e57c5c47ec7250cc7cc1eb3cbf90bf2bc55cf8be 100644 (file)
 #define SCH_DEV(x) do { } while(0)
 #endif
 
-/* ALPN requires version 8.1 of the Windows SDK, which was
-   shipped with Visual Studio 2013, aka _MSC_VER 1800:
-     https://technet.microsoft.com/en-us/library/hh831771%28v=ws.11%29.aspx
-   Or mingw-w64 9.0 or upper.
-*/
-#if (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 9) || \
-  (defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(_USING_V110_SDK71_))
-#  define HAS_ALPN_SCHANNEL
-#endif
-
 #ifndef BCRYPT_CHAIN_MODE_CCM
 #define BCRYPT_CHAIN_MODE_CCM L"ChainingModeCCM"
 #endif
 #define PKCS12_NO_PERSIST_KEY 0x00008000
 #endif
 
+/* ALPN requires version 8.1 of the Windows SDK, which was
+   shipped with Visual Studio 2013, aka _MSC_VER 1800:
+     https://technet.microsoft.com/en-us/library/hh831771%28v=ws.11%29.aspx
+   Or mingw-w64 9.0 or upper.
+*/
+#if (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 9) || \
+  (defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(_USING_V110_SDK71_))
+#define HAS_ALPN_SCHANNEL
 static bool s_win_has_alpn;
+#endif
 
 static CURLcode schannel_pkp_pin_peer_pubkey(struct Curl_cfilter *cf,
                                              struct Curl_easy *data,
@@ -2374,6 +2373,7 @@ static void schannel_close(struct Curl_cfilter *cf, struct Curl_easy *data)
 
 static int schannel_init(void)
 {
+#ifdef HAS_ALPN_SCHANNEL
   bool wine = FALSE;
   bool wine_has_alpn = FALSE;
 
@@ -2399,6 +2399,7 @@ static int schannel_init(void)
     s_win_has_alpn = curlx_verify_windows_version(6, 3, 0, PLATFORM_WINNT,
                                                   VERSION_GREATER_THAN_EQUAL);
   }
+#endif /* HAS_ALPN_SCHANNEL */
 
   return Curl_sspi_global_init() == CURLE_OK ? 1 : 0;
 }