aboutsummaryrefslogtreecommitdiff
path: root/src/dutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/dutil')
-rw-r--r--src/dutil/apuputil.cpp27
-rw-r--r--src/dutil/inc/verutil.h4
-rw-r--r--src/dutil/verutil.cpp16
3 files changed, 29 insertions, 18 deletions
diff --git a/src/dutil/apuputil.cpp b/src/dutil/apuputil.cpp
index 07d591a7..6f5825bb 100644
--- a/src/dutil/apuputil.cpp
+++ b/src/dutil/apuputil.cpp
@@ -208,7 +208,6 @@ static HRESULT ProcessEntry(
208 ) 208 )
209{ 209{
210 HRESULT hr = S_OK; 210 HRESULT hr = S_OK;
211 BOOL fVersionFound = FALSE;
212 int nCompareResult = 0; 211 int nCompareResult = 0;
213 212
214 // First search the ATOM entry's custom elements to try and find the application update information. 213 // First search the ATOM entry's custom elements to try and find the application update information.
@@ -255,25 +254,26 @@ static HRESULT ProcessEntry(
255 { 254 {
256 hr = VerParseVersion(pElement->wzValue, 0, FALSE, &pApupEntry->pVersion); 255 hr = VerParseVersion(pElement->wzValue, 0, FALSE, &pApupEntry->pVersion);
257 ApupExitOnFailure(hr, "Failed to parse version string '%ls' from ATOM entry.", pElement->wzValue); 256 ApupExitOnFailure(hr, "Failed to parse version string '%ls' from ATOM entry.", pElement->wzValue);
258
259 fVersionFound = TRUE;
260 } 257 }
261 } 258 }
262 } 259 }
263 260
264 // If there is no application identity or no version, skip the whole thing. 261 // If there is no application identity or no version, skip the whole thing.
265 if ((!pApupEntry->wzApplicationId && !wzDefaultAppId) || !fVersionFound) 262 if ((!pApupEntry->wzApplicationId && !wzDefaultAppId) || !pApupEntry->pVersion)
266 { 263 {
267 ExitFunction1(hr = S_FALSE); // skip this update since it has no application id or version. 264 ExitFunction1(hr = S_FALSE); // skip this update since it has no application id or version.
268 } 265 }
269 266
270 hr = VerCompareParsedVersions(pApupEntry->pUpgradeVersion, pApupEntry->pVersion, &nCompareResult); 267 if (pApupEntry->pUpgradeVersion)
271 ApupExitOnFailure(hr, "Failed to compare version to upgrade version.");
272
273 if (nCompareResult >= 0)
274 { 268 {
275 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 269 hr = VerCompareParsedVersions(pApupEntry->pUpgradeVersion, pApupEntry->pVersion, &nCompareResult);
276 ApupExitOnRootFailure(hr, "Upgrade version is greater than or equal to application version."); 270 ApupExitOnFailure(hr, "Failed to compare version to upgrade version.");
271
272 if (nCompareResult >= 0)
273 {
274 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
275 ApupExitOnRootFailure(hr, "Upgrade version is greater than or equal to application version.");
276 }
277 } 277 }
278 278
279 if (pAtomEntry->wzTitle) 279 if (pAtomEntry->wzTitle)
@@ -443,11 +443,14 @@ static __callback int __cdecl CompareEntries(
443 VerCompareParsedVersions(pEntryLeft->pUpgradeVersion, pEntryRight->pUpgradeVersion, &ret); 443 VerCompareParsedVersions(pEntryLeft->pUpgradeVersion, pEntryRight->pUpgradeVersion, &ret);
444 if (0 == ret) 444 if (0 == ret)
445 { 445 {
446 ret = (pEntryRight->dw64TotalSize < pEntryLeft->dw64TotalSize) ? -1 : 446 ret = (pEntryLeft->dw64TotalSize < pEntryRight->dw64TotalSize) ? -1 :
447 (pEntryRight->dw64TotalSize > pEntryLeft->dw64TotalSize) ? 1 : 0; 447 (pEntryLeft->dw64TotalSize > pEntryRight->dw64TotalSize) ? 1 : 0;
448 } 448 }
449 } 449 }
450 450
451 // Sort descending.
452 ret = -ret;
453
451 return ret; 454 return ret;
452} 455}
453 456
diff --git a/src/dutil/inc/verutil.h b/src/dutil/inc/verutil.h
index 30869aef..3caa17e1 100644
--- a/src/dutil/inc/verutil.h
+++ b/src/dutil/inc/verutil.h
@@ -34,8 +34,8 @@ typedef struct _VERUTIL_VERSION
34 34
35*******************************************************************/ 35*******************************************************************/
36HRESULT DAPI VerCompareParsedVersions( 36HRESULT DAPI VerCompareParsedVersions(
37 __in VERUTIL_VERSION* pVersion1, 37 __in_opt VERUTIL_VERSION* pVersion1,
38 __in VERUTIL_VERSION* pVersion2, 38 __in_opt VERUTIL_VERSION* pVersion2,
39 __out int* pnResult 39 __out int* pnResult
40 ); 40 );
41 41
diff --git a/src/dutil/verutil.cpp b/src/dutil/verutil.cpp
index 835dde81..fdb5a10a 100644
--- a/src/dutil/verutil.cpp
+++ b/src/dutil/verutil.cpp
@@ -40,8 +40,8 @@ static HRESULT CompareVersionSubstring(
40 40
41 41
42DAPI_(HRESULT) VerCompareParsedVersions( 42DAPI_(HRESULT) VerCompareParsedVersions(
43 __in VERUTIL_VERSION* pVersion1, 43 __in_opt VERUTIL_VERSION* pVersion1,
44 __in VERUTIL_VERSION* pVersion2, 44 __in_opt VERUTIL_VERSION* pVersion2,
45 __out int* pnResult 45 __out int* pnResult
46 ) 46 )
47{ 47{
@@ -50,8 +50,8 @@ DAPI_(HRESULT) VerCompareParsedVersions(
50 DWORD cMaxReleaseLabels = 0; 50 DWORD cMaxReleaseLabels = 0;
51 BOOL fCompareMetadata = FALSE; 51 BOOL fCompareMetadata = FALSE;
52 52
53 if (!pVersion1 || !pVersion1->sczVersion || 53 if (pVersion1 && !pVersion1->sczVersion ||
54 !pVersion2 || !pVersion2->sczVersion) 54 pVersion2 && !pVersion2->sczVersion)
55 { 55 {
56 ExitFunction1(hr = E_INVALIDARG); 56 ExitFunction1(hr = E_INVALIDARG);
57 } 57 }
@@ -60,6 +60,14 @@ DAPI_(HRESULT) VerCompareParsedVersions(
60 { 60 {
61 ExitFunction1(nResult = 0); 61 ExitFunction1(nResult = 0);
62 } 62 }
63 else if (pVersion1 && !pVersion2)
64 {
65 ExitFunction1(nResult = 1);
66 }
67 else if (!pVersion1 && pVersion2)
68 {
69 ExitFunction1(nResult = -1);
70 }
63 71
64 nResult = CompareDword(pVersion1->dwMajor, pVersion2->dwMajor); 72 nResult = CompareDword(pVersion1->dwMajor, pVersion2->dwMajor);
65 if (0 != nResult) 73 if (0 != nResult)