Windows: Fix VerifyVersionInfo calls
- Fix the VerifyVersionInfo calls, which we use to test for the OS major version, to also test for the minor version as well as the service pack major and minor versions. MSDN: "If you are testing the major version, you must also test the minor version and the service pack major and minor versions." https://msdn.microsoft.com/en-us/library/windows/desktop/ms725492.aspx Bug: https://github.com/bagder/curl/pull/353#issuecomment-123493098 Reported-by: Marcel Raad <MarcelRaad@users.noreply.github.com>
This commit is contained in:
@@ -949,16 +949,17 @@ void Curl_sndbufset(curl_socket_t sockfd)
|
|||||||
detectOsState = DETECT_OS_VISTA_OR_LATER;
|
detectOsState = DETECT_OS_VISTA_OR_LATER;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ULONGLONG majorVersionMask;
|
ULONGLONG cm;
|
||||||
OSVERSIONINFOEX osver;
|
OSVERSIONINFOEX osver = { sizeof osver, majorVersion, };
|
||||||
|
|
||||||
memset(&osver, 0, sizeof(osver));
|
cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
osver.dwMajorVersion = majorVersion;
|
cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION,
|
cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
|
||||||
VER_GREATER_EQUAL);
|
|
||||||
|
|
||||||
if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask))
|
if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
|
||||||
|
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
|
||||||
|
cm))
|
||||||
detectOsState = DETECT_OS_VISTA_OR_LATER;
|
detectOsState = DETECT_OS_VISTA_OR_LATER;
|
||||||
else
|
else
|
||||||
detectOsState = DETECT_OS_PREVISTA;
|
detectOsState = DETECT_OS_PREVISTA;
|
||||||
|
@@ -93,20 +93,20 @@ CURLcode Curl_sspi_global_init(void)
|
|||||||
osver.dwPlatformId == platformId)
|
osver.dwPlatformId == platformId)
|
||||||
securityDll = TRUE;
|
securityDll = TRUE;
|
||||||
#else
|
#else
|
||||||
ULONGLONG majorVersionMask;
|
ULONGLONG cm;
|
||||||
ULONGLONG platformIdMask;
|
OSVERSIONINFOEX osver = { sizeof osver, majorVersion, 0, 0, platformId, };
|
||||||
OSVERSIONINFOEX osver;
|
|
||||||
|
|
||||||
memset(&osver, 0, sizeof(osver));
|
cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
|
||||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
osver.dwMajorVersion = majorVersion;
|
cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
osver.dwPlatformId = platformId;
|
cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
|
||||||
majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
|
cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
|
||||||
platformIdMask = VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL);
|
|
||||||
|
|
||||||
/* Verify the major version number == 4 and platform id == WIN_NT */
|
/* Verify the major version number == 4 and platform id == WIN_NT */
|
||||||
if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask) &&
|
if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
|
||||||
VerifyVersionInfo(&osver, VER_PLATFORMID, platformIdMask))
|
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR |
|
||||||
|
VER_PLATFORMID),
|
||||||
|
cm))
|
||||||
securityDll = TRUE;
|
securityDll = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user