From: Timo Sirainen Date: Sat, 21 Apr 2018 12:58:15 +0000 (+0300) Subject: lib-master, util: Consistently truncate tabescaped input at the first NUL X-Git-Tag: 2.3.4~263 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ec04b02fbb91c54be1b6a362d0d483255cb0f31;p=thirdparty%2Fdovecot%2Fcore.git lib-master, util: Consistently truncate tabescaped input at the first NUL The NULs are supposed to come tab-escaped, so there's no need to support actual NUL characters. The previous code truncated at NULs, but could have kept appending more data to the value. This could have produced somewhat random results. --- diff --git a/src/lib-master/master-login.c b/src/lib-master/master-login.c index 06e0a69dea..dffda0c649 100644 --- a/src/lib-master/master-login.c +++ b/src/lib-master/master-login.c @@ -299,7 +299,7 @@ static void master_login_postlogin_input(struct master_login_postlogin *pl) conn_error(conn, "close(client) failed: %m"); pl->client->fd = fd; } - str_append_n(pl->input, buf, ret); + str_append_data(pl->input, buf, ret); } len = str_len(pl->input); diff --git a/src/util/script-login.c b/src/util/script-login.c index 2213edf893..efc9d0de35 100644 --- a/src/util/script-login.c +++ b/src/util/script-login.c @@ -44,7 +44,7 @@ static void client_connected(struct master_service_connection *conn) instr = t_str_new(1024); ret = fd_read(conn->fd, buf, sizeof(buf), &fd); while (ret > 0) { - str_append_n(instr, buf, ret); + str_append_data(instr, buf, ret); if (buf[ret-1] == '\n' && strchr(str_c(instr), '\n')[1] != '\0') { str_truncate(instr, str_len(instr)-1);