diff options
| author | Rob Mensching <rob@firegiant.com> | 2025-11-01 20:24:25 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-11-03 14:49:39 -0800 |
| commit | 4d626c294c4783d454e27ea4e5614037dac8576e (patch) | |
| tree | 51d822f48716e4c5ef2a51ca28925896f221b521 /src/libs/dutil | |
| parent | 33c12fa386aa7ace7a6bd06a45bc3ecf17e9c8f5 (diff) | |
| download | wix-4d626c294c4783d454e27ea4e5614037dac8576e.tar.gz wix-4d626c294c4783d454e27ea4e5614037dac8576e.tar.bz2 wix-4d626c294c4783d454e27ea4e5614037dac8576e.zip | |
Use CompareStringOrdinal() instead of CompareString() case-insensitive
This commit moves to the modern CompareStringOrdinal() for all case-insensitve
uses of CompareString() with the invariant locale.
Partially resolves 6947
Diffstat (limited to 'src/libs/dutil')
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/acl2util.cpp | 2 | ||||
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/apuputil.cpp | 10 | ||||
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/iis7util.cpp | 6 | ||||
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/path2utl.cpp | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/acl2util.cpp b/src/libs/dutil/WixToolset.DUtil/acl2util.cpp index 598f12e7..e62a03d4 100644 --- a/src/libs/dutil/WixToolset.DUtil/acl2util.cpp +++ b/src/libs/dutil/WixToolset.DUtil/acl2util.cpp | |||
| @@ -106,7 +106,7 @@ extern "C" HRESULT DAPI AclGetAccountSidStringEx( | |||
| 106 | HRESULT hrLength = ::StringCchLengthW(wzAccount, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cchAccount)); | 106 | HRESULT hrLength = ::StringCchLengthW(wzAccount, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cchAccount)); |
| 107 | AclExitOnFailure(hrLength, "Failed to get the length of the account name."); | 107 | AclExitOnFailure(hrLength, "Failed to get the length of the account name."); |
| 108 | 108 | ||
| 109 | if (11 < cchAccount && CSTR_EQUAL == CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, L"NT SERVICE\\", 11, wzAccount, 11)) | 109 | if (11 < cchAccount && CSTR_EQUAL == CompareStringOrdinal(L"NT SERVICE\\", 11, wzAccount, 11, TRUE)) |
| 110 | { | 110 | { |
| 111 | // If the service is not installed then LookupAccountName doesn't resolve the SID, but we can calculate it. | 111 | // If the service is not installed then LookupAccountName doesn't resolve the SID, but we can calculate it. |
| 112 | LPCWSTR wzServiceName = &wzAccount[11]; | 112 | LPCWSTR wzServiceName = &wzAccount[11]; |
diff --git a/src/libs/dutil/WixToolset.DUtil/apuputil.cpp b/src/libs/dutil/WixToolset.DUtil/apuputil.cpp index eb96d515..62cf4d06 100644 --- a/src/libs/dutil/WixToolset.DUtil/apuputil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/apuputil.cpp | |||
| @@ -112,7 +112,7 @@ extern "C" HRESULT DAPI ApupAllocChainFromAtom( | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | // Trim the unused entries from the end, if any of the entries failed to parse or validate | 114 | // Trim the unused entries from the end, if any of the entries failed to parse or validate |
| 115 | if (pChain->cEntries != pFeed->cEntries) | 115 | if (pChain->cEntries != pFeed->cEntries) |
| 116 | { | 116 | { |
| 117 | if (pChain->cEntries > 0) | 117 | if (pChain->cEntries > 0) |
| 118 | { | 118 | { |
| @@ -354,22 +354,22 @@ static HRESULT ParseEnclosure( | |||
| 354 | dwDigestLength = 0; | 354 | dwDigestLength = 0; |
| 355 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, L"algorithm", -1, pAttribute->wzAttribute, -1)) | 355 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, L"algorithm", -1, pAttribute->wzAttribute, -1)) |
| 356 | { | 356 | { |
| 357 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"md5", -1, pAttribute->wzValue, -1)) | 357 | if (CSTR_EQUAL == ::CompareStringOrdinal(L"md5", -1, pAttribute->wzValue, -1, TRUE)) |
| 358 | { | 358 | { |
| 359 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_MD5; | 359 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_MD5; |
| 360 | dwDigestLength = MD5_HASH_LEN; | 360 | dwDigestLength = MD5_HASH_LEN; |
| 361 | } | 361 | } |
| 362 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"sha1", -1, pAttribute->wzValue, -1)) | 362 | else if (CSTR_EQUAL == ::CompareStringOrdinal(L"sha1", -1, pAttribute->wzValue, -1, TRUE)) |
| 363 | { | 363 | { |
| 364 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA1; | 364 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA1; |
| 365 | dwDigestLength = SHA1_HASH_LEN; | 365 | dwDigestLength = SHA1_HASH_LEN; |
| 366 | } | 366 | } |
| 367 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"sha256", -1, pAttribute->wzValue, -1)) | 367 | else if (CSTR_EQUAL == ::CompareStringOrdinal(L"sha256", -1, pAttribute->wzValue, -1, TRUE)) |
| 368 | { | 368 | { |
| 369 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA256; | 369 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA256; |
| 370 | dwDigestLength = SHA256_HASH_LEN; | 370 | dwDigestLength = SHA256_HASH_LEN; |
| 371 | } | 371 | } |
| 372 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"sha512", -1, pAttribute->wzValue, -1)) | 372 | else if (CSTR_EQUAL == ::CompareStringOrdinal(L"sha512", -1, pAttribute->wzValue, -1, TRUE)) |
| 373 | { | 373 | { |
| 374 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA512; | 374 | pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA512; |
| 375 | dwDigestLength = SHA512_HASH_LEN; | 375 | dwDigestLength = SHA512_HASH_LEN; |
diff --git a/src/libs/dutil/WixToolset.DUtil/iis7util.cpp b/src/libs/dutil/WixToolset.DUtil/iis7util.cpp index d0a0b000..b0dc1444 100644 --- a/src/libs/dutil/WixToolset.DUtil/iis7util.cpp +++ b/src/libs/dutil/WixToolset.DUtil/iis7util.cpp | |||
| @@ -222,7 +222,7 @@ BOOL DAPI CompareVariantPath( | |||
| 222 | IisExitOnFailure(hr, "Failed to expand path %ls", pVariant2->bstrVal); | 222 | IisExitOnFailure(hr, "Failed to expand path %ls", pVariant2->bstrVal); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | fEqual = CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzValue1, -1, wzValue2, -1); | 225 | fEqual = CSTR_EQUAL == ::CompareStringOrdinal(wzValue1, -1, wzValue2, -1, TRUE); |
| 226 | 226 | ||
| 227 | LExit: | 227 | LExit: |
| 228 | ReleaseNullStr(wzValue1); | 228 | ReleaseNullStr(wzValue1); |
| @@ -258,7 +258,7 @@ extern "C" BOOL DAPI Iis7IsMatchingAppHostElement( | |||
| 258 | 258 | ||
| 259 | hr = pElement->get_Name(&bstrElementName); | 259 | hr = pElement->get_Name(&bstrElementName); |
| 260 | IisExitOnFailure(hr, "Failed to get name of element"); | 260 | IisExitOnFailure(hr, "Failed to get name of element"); |
| 261 | if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pComparison->sczElementName, -1, bstrElementName, -1)) | 261 | if (CSTR_EQUAL != ::CompareStringOrdinal(pComparison->sczElementName, -1, bstrElementName, -1, TRUE)) |
| 262 | { | 262 | { |
| 263 | ExitFunction(); | 263 | ExitFunction(); |
| 264 | } | 264 | } |
| @@ -293,7 +293,7 @@ BOOL DAPI IsMatchingAppHostMethod( | |||
| 293 | 293 | ||
| 294 | Assert(bstrName); | 294 | Assert(bstrName); |
| 295 | 295 | ||
| 296 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzMethodName, -1, bstrName, -1)) | 296 | if (CSTR_EQUAL == ::CompareStringOrdinal(wzMethodName, -1, bstrName, -1, TRUE)) |
| 297 | { | 297 | { |
| 298 | fResult = TRUE; | 298 | fResult = TRUE; |
| 299 | } | 299 | } |
diff --git a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp index d83a4578..06df8617 100644 --- a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp +++ b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp | |||
| @@ -306,7 +306,7 @@ DAPI_(HRESULT) PathCompareCanonicalized( | |||
| 306 | hr = PathCanonicalizeForComparison(wzPath2, dwDefaultFlags, &sczCanonicalized2); | 306 | hr = PathCanonicalizeForComparison(wzPath2, dwDefaultFlags, &sczCanonicalized2); |
| 307 | PathExitOnFailure(hr, "Failed to canonicalize wzPath2."); | 307 | PathExitOnFailure(hr, "Failed to canonicalize wzPath2."); |
| 308 | 308 | ||
| 309 | nResult = ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczCanonicalized1, -1, sczCanonicalized2, -1); | 309 | nResult = ::CompareStringOrdinal(sczCanonicalized1, -1, sczCanonicalized2, -1, TRUE); |
| 310 | PathExitOnNullWithLastError(nResult, hr, "Failed to compare canonicalized paths."); | 310 | PathExitOnNullWithLastError(nResult, hr, "Failed to compare canonicalized paths."); |
| 311 | 311 | ||
| 312 | *pfEqual = CSTR_EQUAL == nResult; | 312 | *pfEqual = CSTR_EQUAL == nResult; |
| @@ -364,7 +364,7 @@ DAPI_(HRESULT) PathDirectoryContainsPath( | |||
| 364 | ExitFunction1(hr = S_FALSE); | 364 | ExitFunction1(hr = S_FALSE); |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | if (CSTR_EQUAL != ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczCanonicalizedDirectory, (DWORD)cchDirectory, sczCanonicalizedPath, (DWORD)cchDirectory)) | 367 | if (CSTR_EQUAL != ::CompareStringOrdinal(sczCanonicalizedDirectory, (DWORD)cchDirectory, sczCanonicalizedPath, (DWORD)cchDirectory, TRUE)) |
| 368 | { | 368 | { |
| 369 | ExitFunction1(hr = S_FALSE); | 369 | ExitFunction1(hr = S_FALSE); |
| 370 | } | 370 | } |
