Skip to content
/ wix Public

Commit 8b9538a

Browse files
committed
Protect against NULL User/Group comment when removing comment
Fixes 8941 (hopefully)
1 parent 6e5d433 commit 8b9538a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/ext/Util/ca/scaexec.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ extern "C" UINT __stdcall CreateUser(
764764
WCA_CASCRIPT_HANDLE hRollbackScript = NULL;
765765
int iOriginalAttributes = 0;
766766
int iRollbackAttributes = 0;
767+
LPCWSTR wzOriginalComment = NULL;
767768

768769
USER_INFO_1 userInfo1;
769770
USER_INFO_1* pUserInfo1 = NULL;
@@ -885,14 +886,16 @@ extern "C" UINT __stdcall CreateUser(
885886
}
886887
}
887888

888-
hr = WcaCaScriptWriteString(hRollbackScript, pUserInfo1->usri1_comment);
889-
ExitOnFailure(hr, "Failed to add rollback comment to rollback script.");
890-
891-
if (!pUserInfo1->usri1_comment || !*pUserInfo1->usri1_comment)
889+
wzOriginalComment = pUserInfo1->usri1_comment;
890+
if (!wzOriginalComment || !*wzOriginalComment)
892891
{
893892
iRollbackAttributes |= SCAU_REMOVE_COMMENT;
893+
wzOriginalComment = L"";
894894
}
895895

896+
hr = WcaCaScriptWriteString(hRollbackScript, wzOriginalComment);
897+
ExitOnFailure(hr, "Failed to add rollback comment to rollback script.");
898+
896899
hr = WcaCaScriptWriteNumber(hRollbackScript, iRollbackAttributes);
897900
ExitOnFailure(hr, "Failed to add rollback attributes to rollback script.");
898901

@@ -1247,6 +1250,7 @@ extern "C" UINT __stdcall CreateGroup(
12471250

12481251
WCA_CASCRIPT_HANDLE hRollbackScript = NULL;
12491252
int iRollbackAttributes = 0;
1253+
LPCWSTR wzOriginalComment = NULL;
12501254

12511255
DWORD dw;
12521256
LPWSTR pwzServerName = NULL;
@@ -1338,14 +1342,16 @@ extern "C" UINT __stdcall CreateGroup(
13381342

13391343
iRollbackAttributes = 0;
13401344

1341-
hr = WcaCaScriptWriteString(hRollbackScript, pGroupInfo1->lgrpi1_comment);
1342-
ExitOnFailure(hr, "Failed to add rollback comment to rollback script.");
1343-
1344-
if (!pGroupInfo1->lgrpi1_comment || !*pGroupInfo1->lgrpi1_comment)
1345+
wzOriginalComment = pGroupInfo1->lgrpi1_comment;
1346+
if (!wzOriginalComment || !*wzOriginalComment)
13451347
{
13461348
iRollbackAttributes |= SCAG_REMOVE_COMMENT;
1349+
wzOriginalComment = L"";
13471350
}
13481351

1352+
hr = WcaCaScriptWriteString(hRollbackScript, wzOriginalComment);
1353+
ExitOnFailure(hr, "Failed to add rollback comment to rollback script.");
1354+
13491355
hr = WcaCaScriptWriteNumber(hRollbackScript, iRollbackAttributes);
13501356
ExitOnFailure(hr, "Failed to add rollback attributes to rollback script.");
13511357

src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public void CanRepairCommentOfNewNonDomainGroup()
243243
}
244244

245245
// Verify that a comment can be changed for an existing group
246-
[RuntimeFact(Skip = "wixtoolset/issues#8941 - This test fails intermittently in CI. Disabling until the root cause is fixed.")]
246+
[RuntimeFact]
247247
public void CanChangeCommentOfExistingNonDomainGroup()
248248
{
249249
try

0 commit comments

Comments
 (0)