summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2015-07-29 16:08:31 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2015-07-29 16:08:31 +0000
commit099da1728c23d5b9a5191ca351421dc0dc079f7e (patch)
treef5190787cb835445f9fed1037730dc14825e3937 /usr/src
parent4b62abf3db26943be3ff46fc210fb740dde70464 (diff)
downloadillumos-joyent-099da1728c23d5b9a5191ca351421dc0dc079f7e.tar.gz
OS-4569 zlogin doesn't properly quote arguments
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zlogin/zlogin.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr/src/cmd/zlogin/zlogin.c b/usr/src/cmd/zlogin/zlogin.c
index 17ea786f42..7c57edc146 100644
--- a/usr/src/cmd/zlogin/zlogin.c
+++ b/usr/src/cmd/zlogin/zlogin.c
@@ -1174,7 +1174,11 @@ prep_args(brand_handle_t bh, char *zonename, const char *login, char **argv)
argc++;
for (i = 0; i < argc; i++) {
- subshell_len += strlen(argv[i]) + 1;
+ /*
+ * Allocate enough space for the delimiter and 2
+ * quotes which might be needed.
+ */
+ subshell_len += strlen(argv[i]) + 3;
}
if ((subshell = calloc(1, subshell_len)) == NULL)
return (NULL);
@@ -1182,7 +1186,13 @@ prep_args(brand_handle_t bh, char *zonename, const char *login, char **argv)
for (i = 0; i < argc; i++) {
if (i > 0)
(void) strcat(subshell, " ");
- (void) strcat(subshell, argv[i]);
+ if (strchr(argv[i], ' ') != NULL) {
+ (void) strcat(subshell, "'");
+ (void) strcat(subshell, argv[i]);
+ (void) strcat(subshell, "'");
+ } else {
+ (void) strcat(subshell, argv[i]);
+ }
}
if (failsafe) {