Skip to content

Commit da4e7e2

Browse files
committed
Support major.minor.build versions in <sparkle:minimumSystemVersion>
Previously much less useful major.minor.servicepack was used, which was of limited practical applicability and is completely useless since Windows 10. To preserve backwards compatiblity, treat low values in the 3rd value of the tuple as service pack version.
1 parent f3708c7 commit da4e7e2

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

Diff for: NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Version 0.8.2
22
-------------
33

4+
- Support major.minor.build versioning scheme in <sparkle:minimumSystemVersion>;
5+
previously only much less useful major.minor.servicepack was used.
46
- Added support for gzip/deflate-compressed appcasts.
57
- Added support for ARM-specific enclosures.
68
- Fixed handling of multiple enclosures to correctly pick the most-specific

Diff for: src/appcast.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,40 @@ namespace
5454

5555
// Misc helper functions:
5656

57-
bool is_compatible_with_windows_version(const Appcast &item)
57+
bool is_compatible_with_windows_version(const Appcast &item_)
5858
{
59+
Appcast item(item_);
60+
61+
item.MinOSVersion = "10";
62+
5963
if (item.MinOSVersion.empty())
6064
return true;
6165

62-
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 };
66+
OSVERSIONINFOEXW osvi = {};
67+
osvi.dwOSVersionInfoSize = sizeof(osvi);
68+
6369
DWORDLONG const dwlConditionMask = VerSetConditionMask(
6470
VerSetConditionMask(
6571
VerSetConditionMask(
6672
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
6773
VER_MINORVERSION, VER_GREATER_EQUAL),
6874
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
6975

70-
sscanf(item.MinOSVersion.c_str(), "%lu.%lu.%hu", &osvi.dwMajorVersion,
71-
&osvi.dwMinorVersion, &osvi.wServicePackMajor);
76+
const int parsed = sscanf(item.MinOSVersion.c_str(), "%lu.%lu.%lu",
77+
&osvi.dwMajorVersion, &osvi.dwMinorVersion, &osvi.dwBuildNumber);
78+
if (parsed == 0)
79+
{
80+
// failed to parse version number, ignore the value
81+
return true;
82+
}
83+
84+
// backwards compatibility with WinSparkle < 0.8.2 which used major.minor.sp
85+
// instead of major.minor.build for the version number:
86+
if (parsed == 3 && osvi.dwBuildNumber < 100)
87+
{
88+
osvi.wServicePackMajor = static_cast<WORD>(osvi.dwBuildNumber);
89+
osvi.dwBuildNumber = 0;
90+
}
7291

7392
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION |
7493
VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;

0 commit comments

Comments
 (0)