aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/version_win32.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-04-13 20:13:40 +0300
committershadchin <shadchin@yandex-team.ru>2022-04-13 20:13:40 +0300
commitad92d4ea3ed939dee26114e765dc7e60eb99349e (patch)
treec9f920ed0d65fca79b89e5e1504808d7b265d49b /contrib/libs/curl/lib/version_win32.c
parentf9c8ebd5329f4efcc759fde08d0540f55d9f7acc (diff)
downloadydb-ad92d4ea3ed939dee26114e765dc7e60eb99349e.tar.gz
CONTRIB-2513 Update contrib/libs/curl to 7.80.0
ref:9f073731f38021df100328c1b343280bf6632e23
Diffstat (limited to 'contrib/libs/curl/lib/version_win32.c')
-rw-r--r--contrib/libs/curl/lib/version_win32.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/contrib/libs/curl/lib/version_win32.c b/contrib/libs/curl/lib/version_win32.c
index b8157e9893..2f845413cc 100644
--- a/contrib/libs/curl/lib/version_win32.c
+++ b/contrib/libs/curl/lib/version_win32.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2016 - 2021, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,11 +26,28 @@
#include <curl/curl.h>
#include "version_win32.h"
+#include "warnless.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"
+/* This Unicode version struct works for VerifyVersionInfoW (OSVERSIONINFOEXW)
+ and RtlVerifyVersionInfo (RTLOSVERSIONINFOEXW) */
+struct OUR_OSVERSIONINFOEXW {
+ ULONG dwOSVersionInfoSize;
+ ULONG dwMajorVersion;
+ ULONG dwMinorVersion;
+ ULONG dwBuildNumber;
+ ULONG dwPlatformId;
+ WCHAR szCSDVersion[128];
+ USHORT wServicePackMajor;
+ USHORT wServicePackMinor;
+ USHORT wSuiteMask;
+ UCHAR wProductType;
+ UCHAR wReserved;
+};
+
/*
* curlx_verify_windows_version()
*
@@ -152,12 +169,23 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
}
#else
ULONGLONG cm = 0;
- OSVERSIONINFOEX osver;
+ struct OUR_OSVERSIONINFOEXW osver;
BYTE majorCondition;
BYTE minorCondition;
BYTE spMajorCondition;
BYTE spMinorCondition;
+ typedef LONG (APIENTRY *RTLVERIFYVERSIONINFO_FN)
+ (struct OUR_OSVERSIONINFOEXW *, ULONG, ULONGLONG);
+ static RTLVERIFYVERSIONINFO_FN pRtlVerifyVersionInfo;
+ static bool onetime = true; /* safe because first call is during init */
+
+ if(onetime) {
+ pRtlVerifyVersionInfo = CURLX_FUNCTION_CAST(RTLVERIFYVERSIONINFO_FN,
+ (GetProcAddress(GetModuleHandleA("ntdll"), "RtlVerifyVersionInfo")));
+ onetime = false;
+ }
+
switch(condition) {
case VERSION_LESS_THAN:
majorCondition = VER_LESS;
@@ -214,10 +242,23 @@ bool curlx_verify_windows_version(const unsigned int majorVersion,
if(platform != PLATFORM_DONT_CARE)
cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
- if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
- VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
- cm))
- matched = TRUE;
+ /* Later versions of Windows have version functions that may not return the
+ real version of Windows unless the application is so manifested. We prefer
+ the real version always, so we use the Rtl variant of the function when
+ possible. Note though the function signatures have underlying fundamental
+ types that are the same, the return values are different. */
+ if(pRtlVerifyVersionInfo) {
+ matched = !pRtlVerifyVersionInfo(&osver,
+ (VER_MAJORVERSION | VER_MINORVERSION |
+ VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
+ cm);
+ }
+ else {
+ matched = !!VerifyVersionInfoW((OSVERSIONINFOEXW *)&osver,
+ (VER_MAJORVERSION | VER_MINORVERSION |
+ VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
+ cm);
+ }
#endif
return matched;