Skip to content

Commit

Permalink
util: script: Amended the protocol to pass arguments escaped to preve…
Browse files Browse the repository at this point in the history
…nt problems with newlines.

Newlines are used as argument delimiters in the protocol, which will cause problems.
  • Loading branch information
stephanbosch authored and GitLab committed May 16, 2017
1 parent fc2b148 commit bcba310
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lib-program-client/program-client-remote.c
Expand Up @@ -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"
Expand Down Expand Up @@ -236,7 +237,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');
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/util/script.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit bcba310

Please sign in to comment.