From 239e658f6b716a2f9ffbdc71418653fbf4de9c56 Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Mon, 23 Mar 2020 18:48:44 -0500 Subject: [PATCH] check for workspace command name arg (fix #5131) For the 'workspace 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. --- sway/commands/workspace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index b911b2f61..a8a2f53b6 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c @@ -140,7 +140,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { break; } } - if (output_location >= 0) { + if (output_location == 0) { + return cmd_results_new(CMD_INVALID, "Expected 'workspace " + " output '"); + } else if (output_location > 0) { if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, output_location + 2))) { return error;