Skip to content

Commit

Permalink
Fix WcaErrorMessage cArgs==-1 case.
Browse files Browse the repository at this point in the history
Count args before creating message record.

Fixes wixtoolset/issues#7422.
Fixes wixtoolset/issues#7444.
  • Loading branch information
barnson committed Apr 25, 2023
1 parent eadea8a commit 3298b9a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/ext/Util/ca/scaexec.cpp
Expand Up @@ -1024,6 +1024,8 @@ extern "C" UINT __stdcall CreateUser(
::CoUninitialize();
}

WcaLog(LOGMSG_VERBOSE, "iAttributes = %d, er = %d, hr = 0x%08x", iAttributes, er, hr);

if (SCAU_NON_VITAL & iAttributes)
{
er = ERROR_SUCCESS;
Expand All @@ -1033,6 +1035,8 @@ extern "C" UINT __stdcall CreateUser(
er = ERROR_INSTALL_FAILURE;
}

WcaLog(LOGMSG_VERBOSE, "iAttributes = %d, er = %d, hr = 0x%08x", iAttributes, er, hr);

return WcaFinalize(er);
}

Expand Down
26 changes: 13 additions & 13 deletions src/libs/wcautil/WixToolset.WcaUtil/wcawrap.cpp
Expand Up @@ -41,6 +41,19 @@ extern "C" UINT __cdecl WcaErrorMessage(
MSIHANDLE hRec = NULL;
va_list args = NULL;

va_start(args, cArgs);
if (-1 == cArgs)
{
LPCWSTR wzArg = NULL;
va_list iter = args;
cArgs = 0;

while (NULL != (wzArg = va_arg(iter, WCHAR*)) && L'\0' != *wzArg)
{
++cArgs;
}
}

uiType |= INSTALLMESSAGE_ERROR; // ensure error type is set
hRec = ::MsiCreateRecord(cArgs + 2);
if (!hRec)
Expand All @@ -55,19 +68,6 @@ extern "C" UINT __cdecl WcaErrorMessage(
er = ::MsiRecordSetInteger(hRec, 2, hrError);
ExitOnFailure(HRESULT_FROM_WIN32(er), "failed to set hresult code into error message");

va_start(args, cArgs);
if (-1 == cArgs)
{
LPCWSTR wzArg = NULL;
va_list iter = args;
cArgs = 0;

while (NULL != (wzArg = va_arg(iter, WCHAR*)) && L'\0' != *wzArg)
{
++cArgs;
}
}

for (INT i = 0; i < cArgs; i++)
{
er = ::MsiRecordSetStringW(hRec, i + 3, va_arg(args, WCHAR*));
Expand Down
2 changes: 1 addition & 1 deletion src/test/burn/WixTestTools/MSIExec.cs
Expand Up @@ -111,7 +111,7 @@ public void SetDefaultArguments()
this.ForceRestart = false;
this.PromptRestart = false;
this.LogFile = String.Empty;
this.LoggingOptions = MSIExecLoggingOptions.VOICEWARMUP;
this.LoggingOptions = MSIExecLoggingOptions.Log_All_Information | MSIExecLoggingOptions.Verbose_Output | MSIExecLoggingOptions.Extra_Debugging_Information; // `/l*vx`
this.OtherArguments = String.Empty;
}

Expand Down

0 comments on commit 3298b9a

Please sign in to comment.