diff options
author | Steve Bennett <steveb@workware.net.au> | 2017-05-11 21:59:37 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2017-05-12 13:02:01 +1000 |
commit | a14d9438b9a67899be0443f39345fa957677f9b8 (patch) | |
tree | 094486a5bcbdf1079786bdc6c1d714bd50178f29 | |
parent | 2a3bfa6b1962af2dfb5c6e49d6dd6b3a39714df9 (diff) | |
download | jimtcl-a14d9438b9a67899be0443f39345fa957677f9b8.zip jimtcl-a14d9438b9a67899be0443f39345fa957677f9b8.tar.gz jimtcl-a14d9438b9a67899be0443f39345fa957677f9b8.tar.bz2 |
exec: Fix check for | and |&
These are only allowed as separate args. One check was allowing
them as a prefix which could lead to an invalid memory access
Reported-by: Ryan Whitworth <me@ryanwhitworth.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-exec.c | 9 | ||||
-rw-r--r-- | regtest.tcl | 5 |
2 files changed, 10 insertions, 4 deletions
@@ -959,10 +959,11 @@ badargs: fdtype origErrorId = errorId; for (lastArg = firstArg; lastArg < arg_count; lastArg++) { - if (arg_array[lastArg][0] == '|') { - if (arg_array[lastArg][1] == '&') { - pipe_dup_err = 1; - } + if (strcmp(arg_array[lastArg], "|") == 0) { + break; + } + if (strcmp(arg_array[lastArg], "|&") == 0) { + pipe_dup_err = 1; break; } } diff --git a/regtest.tcl b/regtest.tcl index 5bc3227..7b67586 100644 --- a/regtest.tcl +++ b/regtest.tcl @@ -300,6 +300,11 @@ puts "TEST 40 PASSED" catch {scan x %3} puts "TEST 41 PASSED" +# REGTEST 42 +# | and |& are not acceptable as prefixes +catch {exec dummy |x second} +puts "TEST 42 PASSED" + # TAKE THE FOLLOWING puts AS LAST LINE puts "--- ALL TESTS PASSED ---" |