]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master, util: Consistently truncate tabescaped input at the first NUL
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 21 Apr 2018 12:58:15 +0000 (15:58 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Aug 2018 08:12:37 +0000 (11:12 +0300)
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.

src/lib-master/master-login.c
src/util/script-login.c

index 06e0a69deaa0705c8811f785bd123c0f0e61c3fa..dffda0c6491b1ddef56c3933bfe3331c443c6ae7 100644 (file)
@@ -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);
index 2213edf893e7327d79b260e470bfcf6c70ac0c65..efc9d0de3567fc06e63ee8f51bd50f4b0b1a054b 100644 (file)
@@ -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);