Mercurial > dovecot > core-2.2
changeset 22069:e6d9a30177c5
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.
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Mon, 08 May 2017 12:48:08 +0200 |
parents | f294b577cf76 |
children | ded950b2b5d2 |
files | src/lib-program-client/program-client-remote.c src/util/script.c |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-program-client/program-client-remote.c Tue May 09 13:43:39 2017 +0200 +++ b/src/lib-program-client/program-client-remote.c Mon May 08 12:48:08 2017 +0200 @@ -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 @@ 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'); } }
--- a/src/util/script.c Tue May 09 13:43:39 2017 +0200 +++ b/src/util/script.c Mon May 08 12:48:08 2017 +0200 @@ -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 @@ 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();