1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Fix help when a valid option is invalid for the specified command.

Getting help for a valid option that was invalid for the command would segfault.

Add a check to ensure the option is valid for the command's default role.
This commit is contained in:
David Steele
2021-04-22 11:48:04 -04:00
committed by GitHub
parent 72dac5b10b
commit 45f83558ea
3 changed files with 31 additions and 3 deletions

View File

@ -307,6 +307,14 @@ testRun(void)
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse bogus option");
TEST_ERROR(helpRender(), OptionInvalidError, "option 'BOGUS' is not valid for command 'archive-push'");
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
strLstAddZ(argList, CFGCMD_HELP);
strLstAddZ(argList, CFGCMD_ARCHIVE_PUSH);
strLstAddZ(argList, CFGOPT_PROCESS);
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse option invalid for command");
TEST_ERROR(helpRender(), OptionInvalidError, "option 'process' is not valid for command 'archive-push'");
// -------------------------------------------------------------------------------------------------------------------------
const char *optionHelp = strZ(strNewFmt(
"%s - 'archive-push' command - 'buffer-size' option help\n"