Fixed the display of version help.

Writing the help to stdout from within the sandbox doesn't work, as intended.
This commit is contained in:
Kelby Murie 2023-01-06 15:57:54 +11:00
parent 31d5ca8179
commit a7b8c20972
2 changed files with 12 additions and 8 deletions

View File

@ -99,6 +99,7 @@ escape vectors.
* Updated to the latest Chromium Sandbox [as of 2022-12-15](https://chromium.googlesource.com/chromium/src/+/1a554a4863f66c922398e91691212a54a8f11ea0)).
* Fixed the sandbox tests to no longer report a missing output file.
* Fixed the sandbox failure tests to run when requested.
* Fixed the display of the version help (-h).
### [1.3.9.27] - 2019-06-14
* __Breaking change: installer now includes 64-bit binaries only.__

View File

@ -430,10 +430,20 @@ static void ApplyPolicy(std::unique_ptr<sandbox::TargetPolicy> &policy, int argc
// Allow WRITE access to OutputFile target directory
BOOL has_outfile = FALSE;
BOOL test_enabled = FALSE;
BOOL help_requested = FALSE;
int i;
for (i = 0; i < argc; ++i) {
wchar_t *p;
if (wcscmp(argv[i], L"-h") == 0) {
printf("Ghost Trap: GPL Ghostscript running in the Google Chromium Sandbox.\n");
printf("Ghost Trap: Version %s\n", GHOST_TRAP_VERSION);
printf("Ghost Trap: %s\n", GHOST_TRAP_COPYRIGHT);
printf("\n");
help_requested = TRUE;
continue;
}
if ((p = wcsstr(nargv[i], PARAM_OUTPUT_FILE)) != NULL) {
p += wcslen(PARAM_OUTPUT_FILE);
AllowAccessToFile(policy, p, TRUE);
@ -494,7 +504,7 @@ static void ApplyPolicy(std::unique_ptr<sandbox::TargetPolicy> &policy, int argc
}
// If no OutputFile, add READ/WRITE access to current working directory?
if (!has_outfile && !test_enabled) {
if (!has_outfile && !test_enabled && !help_requested) {
fprintf(stderr, "Ghost Trap: An OutputFile with an absolute path is required.\n");
}
@ -619,13 +629,6 @@ static int TestSandbox() {
static int SandboxedMain(int argc, wchar_t* argv[]) {
// If -h, print out Ghost Trap information as well.
for (int i = 0; i < argc; ++i) {
if (wcscmp(argv[i], L"-h") == 0) {
printf("Ghost Trap: GPL Ghostscript running in with the Google Chromium Sandbox.\n");
printf("Ghost Trap: Version %s\n", GHOST_TRAP_VERSION);
printf("Ghost Trap: %s\n", GHOST_TRAP_COPYRIGHT);
printf("\n");
break;
}
// Used for developer testing only (not documented in usage)
if (wcscmp(argv[i], L"--test-sandbox") == 0) {
return TestSandbox();