diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-10-29 20:11:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-10-29 20:11:58 +0000 |
commit | 4226b5d1642be7873fd960efbfc7c3c110fb958d (patch) | |
tree | 6d62acd3e53614cf51a47d4a834894ed9c124eab /usr.bin/tmux/cmd.c | |
parent | b2dd5f2d10c32898c163ed30513d809b3df73bbd (diff) |
We now send argv to the server after parsing it in the client to get the
command, so the client should not modify it. Instead, take a copy. Fixes
parsing command lists, reported by mcbride@.
Diffstat (limited to 'usr.bin/tmux/cmd.c')
-rw-r--r-- | usr.bin/tmux/cmd.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index 280dd9cffd6..b4fa4dbccc2 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.45 2010/10/23 13:04:34 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.46 2010/10/29 20:11:57 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -166,6 +166,22 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv) return (0); } +char ** +cmd_copy_argv(int argc, char **argv) +{ + char **new_argv; + int i; + + if (argc == 0) + return (NULL); + new_argv = xcalloc(argc, sizeof *new_argv); + for (i = 0; i < argc; i++) { + if (argv[i] != NULL) + new_argv[i] = xstrdup(argv[i]); + } + return (new_argv); +} + void cmd_free_argv(int argc, char **argv) { |