aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-01-23 14:26:45 -0500
committerDrew DeVault <sir@cmpwn.com>2016-01-23 14:26:45 -0500
commit78b2808c52e9a535693776433c3c92426baff611 (patch)
tree080a88e1c233da085636465f0da9bdcb15dd33bd /sway/commands.c
parent06f6552eeda696242201cc0997d1e36cb45a7103 (diff)
parent449617f10465f685112415239420affbca9a389f (diff)
Merge pull request #465 from sardemff7/master
Some fixes in commands/assign
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f6326038..9f6e5032 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -169,15 +169,18 @@ static struct cmd_results *cmd_assign(int argc, char **argv) {
char *criteria = *argv++;
- if (strncmp(*argv, "→", 1) == 0) {
+ if (strncmp(*argv, "→", strlen("→")) == 0) {
+ if (argc < 3) {
+ return cmd_results_new(CMD_INVALID, "assign", "Missing workspace");
+ }
argv++;
}
char *movecmd = "move container to workspace ";
- int arglen = strlen(*argv);
- char *cmdlist = calloc(1, sizeof(movecmd) + arglen);
+ int arglen = strlen(movecmd) + strlen(*argv) + 1;
+ char *cmdlist = calloc(1, arglen);
- sprintf(cmdlist, "%s%s", movecmd, *argv);
+ snprintf(cmdlist, arglen, "%s%s", movecmd, *argv);
struct criteria *crit = malloc(sizeof(struct criteria));
crit->crit_raw = strdup(criteria);