diff options
author | 2016-06-29 12:53:35 -0400 | |
---|---|---|
committer | 2016-06-29 12:53:35 -0400 | |
commit | 74a9ffe66e0f4e41bccea80783c5ac946c3ac51e (patch) | |
tree | 7ca58dfd1b433dd1544954a970adcb8c79c620f4 | |
parent | fixing ampersand url (diff) | |
download | firejail-74a9ffe66e0f4e41bccea80783c5ac946c3ac51e.tar.gz firejail-74a9ffe66e0f4e41bccea80783c5ac946c3ac51e.tar.zst firejail-74a9ffe66e0f4e41bccea80783c5ac946c3ac51e.zip |
fixed broken argument functionality
-rw-r--r-- | src/firejail/join.c | 12 | ||||
-rw-r--r-- | src/firejail/no_sandbox.c | 12 | ||||
-rw-r--r-- | src/firejail/run_symlink.c | 15 |
3 files changed, 28 insertions, 11 deletions
diff --git a/src/firejail/join.c b/src/firejail/join.c index 5a2c02d63..aba8f064b 100644 --- a/src/firejail/join.c +++ b/src/firejail/join.c | |||
@@ -61,9 +61,15 @@ static void extract_command(int argc, char **argv, int index) { | |||
61 | cfg.command_line = malloc(len + 1); | 61 | cfg.command_line = malloc(len + 1); |
62 | *cfg.command_line = '\0'; | 62 | *cfg.command_line = '\0'; |
63 | for (i = index; i < argc; i++) { | 63 | for (i = index; i < argc; i++) { |
64 | strcat(cfg.command_line, "\""); | 64 | if (strchr(argv[i], '&')) { |
65 | strcat(cfg.command_line, argv[i]); | 65 | strcat(cfg.command_line, "\""); |
66 | strcat(cfg.command_line, "\" "); | 66 | strcat(cfg.command_line, argv[i]); |
67 | strcat(cfg.command_line, "\" "); | ||
68 | } | ||
69 | else { | ||
70 | strcat(cfg.command_line, argv[i]); | ||
71 | strcat(cfg.command_line, " "); | ||
72 | } | ||
67 | } | 73 | } |
68 | if (arg_debug) | 74 | if (arg_debug) |
69 | printf("Extracted command #%s#\n", cfg.command_line); | 75 | printf("Extracted command #%s#\n", cfg.command_line); |
diff --git a/src/firejail/no_sandbox.c b/src/firejail/no_sandbox.c index f6ad3d472..898803615 100644 --- a/src/firejail/no_sandbox.c +++ b/src/firejail/no_sandbox.c | |||
@@ -191,9 +191,15 @@ void run_no_sandbox(int argc, char **argv) { | |||
191 | 191 | ||
192 | // copy | 192 | // copy |
193 | for (i = start_index; i < argc; i++) { | 193 | for (i = start_index; i < argc; i++) { |
194 | strcat(command, "\""); | 194 | if (strchr(argv[i], '&')) { |
195 | strcat(command, argv[i]); | 195 | strcat(command, "\""); |
196 | strcat(command, "\" "); | 196 | strcat(command, argv[i]); |
197 | strcat(command, "\" "); | ||
198 | } | ||
199 | else { | ||
200 | strcat(command, argv[i]); | ||
201 | strcat(command, " "); | ||
202 | } | ||
197 | } | 203 | } |
198 | } | 204 | } |
199 | 205 | ||
diff --git a/src/firejail/run_symlink.c b/src/firejail/run_symlink.c index 554d243e5..26c6c5133 100644 --- a/src/firejail/run_symlink.c +++ b/src/firejail/run_symlink.c | |||
@@ -103,11 +103,16 @@ void run_symlink(int argc, char **argv) { | |||
103 | a[1] = program; | 103 | a[1] = program; |
104 | int i; | 104 | int i; |
105 | for (i = 0; i < (argc - 1); i++) { | 105 | for (i = 0; i < (argc - 1); i++) { |
106 | char *str = malloc(strlen(argv[i + 1])); | 106 | // look for & character |
107 | if (str == NULL) | 107 | if (strchr(argv[i + 1], '&')) { |
108 | errExit("malloc"); | 108 | char *str = malloc(strlen(argv[i + 1])); |
109 | sprintf(str, "\"%s\"", argv[i + 1]); | 109 | if (str == NULL) |
110 | a[i + 2] = str; | 110 | errExit("malloc"); |
111 | sprintf(str, "\"%s\"", argv[i + 1]); | ||
112 | a[i + 2] = str; | ||
113 | } | ||
114 | else | ||
115 | a[i + 2] = argv[i + 1]; | ||
111 | } | 116 | } |
112 | a[i + 2] = NULL; | 117 | a[i + 2] = NULL; |
113 | execvp(a[0], a); | 118 | execvp(a[0], a); |