summaryrefslogtreecommitdiff
path: root/lib/curl_sspi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/curl_sspi.c')
-rw-r--r--lib/curl_sspi.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c
index e747d86b1..5a48e4943 100644
--- a/lib/curl_sspi.c
+++ b/lib/curl_sspi.c
@@ -68,25 +68,51 @@ PSecurityFunctionTable s_pSecFn = NULL;
*/
CURLcode Curl_sspi_global_init(void)
{
- OSVERSIONINFO osver;
+ bool securityDll = FALSE;
INITSECURITYINTERFACE_FN pInitSecurityInterface;
/* If security interface is not yet initialized try to do this */
if(!s_hSecDll) {
+ /* Security Service Provider Interface (SSPI) functions are located in
+ * security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
+ * have both these DLLs (security.dll forwards calls to secur32.dll) */
+ DWORD majorVersion = 4;
+ DWORD platformId = VER_PLATFORM_WIN32_NT;
+
+#if !defined(VerifyVersionInfo)
+ OSVERSIONINFO osver;
- /* Find out Windows version */
memset(&osver, 0, sizeof(osver));
osver.dwOSVersionInfoSize = sizeof(osver);
+
+ /* Find out Windows version */
if(!GetVersionEx(&osver))
return CURLE_FAILED_INIT;
- /* Security Service Provider Interface (SSPI) functions are located in
- * security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
- * have both these DLLs (security.dll forwards calls to secur32.dll) */
+ /* Verify the major version number == 4 and platform id == WIN_NT */
+ if(osver.dwMajorVersion == majorVersion &&
+ osver.dwPlatformId == platformId)
+ securityDll = TRUE;
+#else
+ ULONGLONG majorVersionMask;
+ ULONGLONG platformIdMask;
+ OSVERSIONINFOEX osver;
+
+ memset(&osver, 0, sizeof(osver));
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ osver.dwMajorVersion = majorVersion;
+ osver.dwPlatformId = platformId;
+ majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
+ platformIdMask = VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL);
+
+ /* Verify the major version number == 4 and platform id == WIN_NT */
+ if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask) &&
+ VerifyVersionInfo(&osver, VER_PLATFORMID, platformIdMask))
+ securityDll = TRUE;
+#endif
/* Load SSPI dll into the address space of the calling process */
- if(osver.dwPlatformId == VER_PLATFORM_WIN32_NT
- && osver.dwMajorVersion == 4)
+ if(securityDll)
s_hSecDll = LoadLibrary(TEXT("security.dll"));
else
s_hSecDll = LoadLibrary(TEXT("secur32.dll"));