]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
util: script: Amended the protocol to pass arguments escaped to prevent problems...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 8 May 2017 10:48:08 +0000 (12:48 +0200)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 23 May 2017 11:39:28 +0000 (13:39 +0200)
Newlines are used as argument delimiters in the protocol, which will cause problems.

src/lib-program-client/program-client-remote.c
src/util/script.c

index 11e4b640a6926f2aeaed3da1ff60747d5c0bb16a..2b1add6ee7faa0a2cfee4f8174870d2ea54ea946 100644 (file)
@@ -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');
                }
        }
index bae5af2dd8e0ad853c816a9c31fd655689c72363..0ad756fb1067a0420a6e2d0b8c58e2add222fde2 100644 (file)
@@ -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();