Require clean room switch to be first argument and catch embedded switch specified with other modes in the clean room process.
Sean Hall committed
Aug 3, 2021 at 15:43 UTC
25ae58ec05bec0b97038e98eec9582209c1f9583
2 files changed
+18
-5
src/burn/engine/core.cpp
+17
-5
@@ -1521,7 +1521,7 @@ extern "C" HRESULT CoreParseCommandLine(
1521
ExitOnRootFailure(hr = E_INVALIDARG, "Must specify the elevated name, token and parent process id.");
1522
}
1523
1524
- if (BURN_MODE_UNTRUSTED != pInternalCommand->mode)
1524
+ if (BURN_MODE_UNKNOWN != pInternalCommand->mode)
1525
{
1526
fInvalidCommandLine = TRUE;
1527
TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
@@ -1543,7 +1543,13 @@ extern "C" HRESULT CoreParseCommandLine(
1543
}
1544
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM), BURN_COMMANDLINE_SWITCH_CLEAN_ROOM, lstrlenW(BURN_COMMANDLINE_SWITCH_CLEAN_ROOM)))
1545
{
1546
- if (BURN_MODE_UNTRUSTED == pInternalCommand->mode)
1546
+ if (0 != i)
1547
+ {
1548
+ fInvalidCommandLine = TRUE;
1549
+ TraceLog(E_INVALIDARG, "Clean room command-line switch must be first argument on command-line.");
1550
+ }
1551
+
1552
+ if (BURN_MODE_UNKNOWN == pInternalCommand->mode)
1553
{
1554
pInternalCommand->mode = BURN_MODE_NORMAL;
1555
}
@@ -1579,8 +1585,9 @@ extern "C" HRESULT CoreParseCommandLine(
1585
1586
switch (pInternalCommand->mode)
1587
{
1582
- case BURN_MODE_UNTRUSTED:
1583
- // Leave mode as UNTRUSTED to launch the clean room process.
1588
+ case BURN_MODE_UNKNOWN:
1589
+ // Set mode to UNTRUSTED to ensure multiple modes weren't specified.
1590
+ pInternalCommand->mode = BURN_MODE_UNTRUSTED;
1591
break;
1592
case BURN_MODE_NORMAL:
1593
// The initialization code already assumes that the
@@ -1647,7 +1654,7 @@ extern "C" HRESULT CoreParseCommandLine(
1654
}
1655
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1))
1656
{
1650
- if (BURN_MODE_UNTRUSTED != pInternalCommand->mode)
1657
+ if (BURN_MODE_UNKNOWN != pInternalCommand->mode)
1658
{
1659
fInvalidCommandLine = TRUE;
1660
TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
@@ -1797,6 +1804,11 @@ extern "C" HRESULT CoreParseCommandLine(
1804
pCommand->display = BOOTSTRAPPER_DISPLAY_FULL;
1805
}
1806
1807
+ if (BURN_MODE_UNKNOWN == pInternalCommand->mode)
1808
+ {
1809
+ pInternalCommand->mode = BURN_MODE_UNTRUSTED;
1810
+ }
1811
+
1812
LExit:
1813
if (fInvalidCommandLine)
1814
{
src/burn/engine/core.h
+1
@@ -62,6 +62,7 @@ const LPCWSTR BURN_BUNDLE_LAST_USED_SOURCE = L"WixBundleLastUsedSource";
62
63
enum BURN_MODE
64
{
65
+ BURN_MODE_UNKNOWN,
66
BURN_MODE_UNTRUSTED,
67
BURN_MODE_NORMAL,
68
BURN_MODE_ELEVATED,