diff options
Diffstat (limited to '')
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/verutil.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/verutil.cpp b/src/libs/dutil/WixToolset.DUtil/verutil.cpp index 8881d7bc..30b979b1 100644 --- a/src/libs/dutil/WixToolset.DUtil/verutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/verutil.cpp | |||
| @@ -194,6 +194,7 @@ DAPI_(HRESULT) VerCopyVersion( | |||
| 194 | hr = StrAllocString(&pCopy->sczVersion, pSource->sczVersion, 0); | 194 | hr = StrAllocString(&pCopy->sczVersion, pSource->sczVersion, 0); |
| 195 | VerExitOnFailure(hr, "Failed to copy Verutil version string '%ls'.", pSource->sczVersion); | 195 | VerExitOnFailure(hr, "Failed to copy Verutil version string '%ls'.", pSource->sczVersion); |
| 196 | 196 | ||
| 197 | pCopy->chPrefix = pSource->chPrefix; | ||
| 197 | pCopy->dwMajor = pSource->dwMajor; | 198 | pCopy->dwMajor = pSource->dwMajor; |
| 198 | pCopy->dwMinor = pSource->dwMinor; | 199 | pCopy->dwMinor = pSource->dwMinor; |
| 199 | pCopy->dwPatch = pSource->dwPatch; | 200 | pCopy->dwPatch = pSource->dwPatch; |
| @@ -251,6 +252,7 @@ DAPI_(HRESULT) VerParseVersion( | |||
| 251 | { | 252 | { |
| 252 | HRESULT hr = S_OK; | 253 | HRESULT hr = S_OK; |
| 253 | VERUTIL_VERSION* pVersion = NULL; | 254 | VERUTIL_VERSION* pVersion = NULL; |
| 255 | LPCWSTR wzString = NULL; | ||
| 254 | LPCWSTR wzEnd = NULL; | 256 | LPCWSTR wzEnd = NULL; |
| 255 | LPCWSTR wzPartBegin = NULL; | 257 | LPCWSTR wzPartBegin = NULL; |
| 256 | LPCWSTR wzPartEnd = NULL; | 258 | LPCWSTR wzPartEnd = NULL; |
| @@ -277,22 +279,22 @@ DAPI_(HRESULT) VerParseVersion( | |||
| 277 | VerExitOnRootFailure(hr = E_INVALIDARG, "Version string is too long: %Iu", cchVersion); | 279 | VerExitOnRootFailure(hr = E_INVALIDARG, "Version string is too long: %Iu", cchVersion); |
| 278 | } | 280 | } |
| 279 | 281 | ||
| 280 | if (L'v' == *wzVersion || L'V' == *wzVersion) | ||
| 281 | { | ||
| 282 | ++wzVersion; | ||
| 283 | --cchVersion; | ||
| 284 | } | ||
| 285 | |||
| 286 | pVersion = reinterpret_cast<VERUTIL_VERSION*>(MemAlloc(sizeof(VERUTIL_VERSION), TRUE)); | 282 | pVersion = reinterpret_cast<VERUTIL_VERSION*>(MemAlloc(sizeof(VERUTIL_VERSION), TRUE)); |
| 287 | VerExitOnNull(pVersion, hr, E_OUTOFMEMORY, "Failed to allocate memory for Verutil version '%ls'.", wzVersion); | 283 | VerExitOnNull(pVersion, hr, E_OUTOFMEMORY, "Failed to allocate memory for Verutil version '%ls'.", wzVersion); |
| 288 | 284 | ||
| 289 | hr = StrAllocString(&pVersion->sczVersion, wzVersion, cchVersion); | 285 | wzString = wzVersion; |
| 290 | VerExitOnFailure(hr, "Failed to copy Verutil version string '%ls'.", wzVersion); | 286 | |
| 287 | if (L'v' == *wzString || L'V' == *wzString) | ||
| 288 | { | ||
| 289 | pVersion->chPrefix = *wzString; | ||
| 290 | ++wzString; | ||
| 291 | --cchVersion; | ||
| 292 | } | ||
| 291 | 293 | ||
| 292 | wzVersion = wzPartBegin = wzPartEnd = pVersion->sczVersion; | 294 | wzPartBegin = wzPartEnd = wzString; |
| 293 | 295 | ||
| 294 | // Save end pointer. | 296 | // Save end pointer. |
| 295 | wzEnd = wzVersion + cchVersion; | 297 | wzEnd = wzString + cchVersion; |
| 296 | 298 | ||
| 297 | // Parse version number | 299 | // Parse version number |
| 298 | while (wzPartBegin < wzEnd) | 300 | while (wzPartBegin < wzEnd) |
| @@ -473,7 +475,7 @@ DAPI_(HRESULT) VerParseVersion( | |||
| 473 | pReleaseLabel->dwValue = uLabel; | 475 | pReleaseLabel->dwValue = uLabel; |
| 474 | } | 476 | } |
| 475 | 477 | ||
| 476 | pReleaseLabel->cchLabelOffset = wzPartBegin - pVersion->sczVersion; | 478 | pReleaseLabel->cchLabelOffset = wzPartBegin - wzString; |
| 477 | pReleaseLabel->cchLabel = cchLabel; | 479 | pReleaseLabel->cchLabel = cchLabel; |
| 478 | 480 | ||
| 479 | if (fTrailingDot) | 481 | if (fTrailingDot) |
| @@ -507,9 +509,20 @@ DAPI_(HRESULT) VerParseVersion( | |||
| 507 | ExitFunction1(hr = E_INVALIDARG); | 509 | ExitFunction1(hr = E_INVALIDARG); |
| 508 | } | 510 | } |
| 509 | 511 | ||
| 510 | pVersion->cchMetadataOffset = min(wzPartBegin, wzEnd) - pVersion->sczVersion; | 512 | pVersion->cchMetadataOffset = min(wzPartBegin, wzEnd) - wzString; |
| 511 | pVersion->fInvalid = fInvalid; | 513 | pVersion->fInvalid = fInvalid; |
| 512 | 514 | ||
| 515 | // If the whole string was invalid, then don't clip off the prefix. | ||
| 516 | if (!pVersion->cchMetadataOffset && pVersion->chPrefix) | ||
| 517 | { | ||
| 518 | pVersion->chPrefix = '\0'; | ||
| 519 | wzString = wzVersion; | ||
| 520 | ++cchVersion; | ||
| 521 | } | ||
| 522 | |||
| 523 | hr = StrAllocString(&pVersion->sczVersion, wzString, cchVersion); | ||
| 524 | VerExitOnFailure(hr, "Failed to copy Verutil version string '%ls'.", wzVersion); | ||
| 525 | |||
| 513 | *ppVersion = pVersion; | 526 | *ppVersion = pVersion; |
| 514 | pVersion = NULL; | 527 | pVersion = NULL; |
| 515 | hr = S_OK; | 528 | hr = S_OK; |
