From: Stephan Bosch Date: Mon, 8 May 2017 10:48:08 +0000 (+0200) Subject: util: script: Amended the protocol to pass arguments escaped to prevent problems... X-Git-Tag: 2.2.30.rc1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2dcb39ce519212f845fd6950f26f6c7efe5232e4;p=thirdparty%2Fdovecot%2Fcore.git util: script: Amended the protocol to pass arguments escaped to prevent problems with newlines. Newlines are used as argument delimiters in the protocol, which will cause problems. --- diff --git a/src/lib-program-client/program-client-remote.c b/src/lib-program-client/program-client-remote.c index 11e4b640a6..2b1add6ee7 100644 --- a/src/lib-program-client/program-client-remote.c +++ b/src/lib-program-client/program-client-remote.c @@ -4,6 +4,7 @@ #include "lib.h" #include "ioloop.h" #include "str.h" +#include "strescape.h" #include "net.h" #include "write-full.h" #include "eacces-error.h" @@ -220,7 +221,7 @@ void program_client_remote_connected(struct program_client *pclient) str_append(str, "-\n"); if (args != NULL) { for(; *args != NULL; args++) { - str_append(str, *args); + str_append_tabescaped(str, *args); str_append_c(str, '\n'); } } diff --git a/src/util/script.c b/src/util/script.c index bae5af2dd8..0ad756fb10 100644 --- a/src/util/script.c +++ b/src/util/script.c @@ -3,6 +3,7 @@ #include "lib.h" #include "array.h" #include "str.h" +#include "strescape.h" #include "env-util.h" #include "execv-const.h" #include "write-full.h" @@ -51,8 +52,10 @@ exec_child(struct master_service_connection *conn, const char *const *args) if (close(conn->fd) < 0) i_error("close(conn->fd) failed: %m"); - for (; *args != NULL; args++) - array_append(&exec_args, args, 1); + for (; *args != NULL; args++) { + const char *arg = t_str_tabunescape(*args); + array_append(&exec_args, &arg, 1); + } array_append_zero(&exec_args); env_clean();