mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
check for workspace command name arg
* check for workspace command name arg (fix #5131) For the 'workspace <name> output <output>' command, output_location must be greater than zero or the attempt to get the workspace name with join_args will segfault or abort() (depending on the flavor of sway_assert() in use). This checks and returns an error instead. * put workspace output error string on one line To ease grepping as requested * check for name in workspace gaps command as well A malformed command here will lead to the same result seen in #5131, so add a check. Done inside the cmd_workspace_gaps() function itself, to take advantage of the existing 'Expected...' string.
This commit is contained in:
parent
0b9feb6f39
commit
854497b242
1 changed files with 7 additions and 1 deletions
|
@ -60,6 +60,9 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
|
||||||
int gaps_location) {
|
int gaps_location) {
|
||||||
const char expected[] = "Expected 'workspace <name> gaps "
|
const char expected[] = "Expected 'workspace <name> gaps "
|
||||||
"inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
|
"inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
|
||||||
|
if (gaps_location == 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID, expected);
|
||||||
|
}
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO,
|
if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO,
|
||||||
gaps_location + 3))) {
|
gaps_location + 3))) {
|
||||||
|
@ -140,7 +143,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (output_location >= 0) {
|
if (output_location == 0) {
|
||||||
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
"Expected 'workspace <name> output <output>'");
|
||||||
|
} else if (output_location > 0) {
|
||||||
if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST,
|
if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST,
|
||||||
output_location + 2))) {
|
output_location + 2))) {
|
||||||
return error;
|
return error;
|
||||||
|
|
Loading…
Reference in a new issue