summaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-10-29 20:11:57 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-10-29 20:11:57 +0000
commit34d05ea7cdc168f3f40ee8f7c1f203a216f2dfdf (patch)
tree32c055e3a54ed70f4ac3dcbf9ba55d5d128752b9 /cmd.c
parent5de84eca3dbaa7b9fcc378a58198ced8a2d95a3e (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 'cmd.c')
-rw-r--r--cmd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd.c b/cmd.c
index 20cf9cdc..af038b7b 100644
--- a/cmd.c
+++ b/cmd.c
@@ -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)
{