Bug 1219369: In Windows debug builds allow write access to TEMP for logging purposes. r=tabraldes

This commit is contained in:
Bob Owen 2016-02-09 08:31:18 +00:00
parent 56265354f6
commit 9482163d8e

View File

@ -53,6 +53,21 @@ SandboxBroker::LaunchApp(const wchar_t *aPath,
mozilla::sandboxing::ApplyLoggingPolicy(*mPolicy);
}
#if defined(DEBUG)
// Allow write access to TEMP directory in debug builds for logging purposes.
// The path from GetTempPathW can have a length up to MAX_PATH + 1, including
// the null, so we need MAX_PATH + 2, so we can add an * to the end.
wchar_t tempPath[MAX_PATH + 2];
uint32_t pathLen = ::GetTempPathW(MAX_PATH + 1, tempPath);
if (pathLen > 0) {
// GetTempPath path ends with \ and returns the length without the null.
tempPath[pathLen] = L'*';
tempPath[pathLen + 1] = L'\0';
mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
sandbox::TargetPolicy::FILES_ALLOW_ANY, tempPath);
}
#endif
// Ceate the sandboxed process
PROCESS_INFORMATION targetInfo = {0};
sandbox::ResultCode result;