Skip to content

Commit

Permalink
lib-master, util: Consistently truncate tabescaped input at the first…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
sirainen committed Aug 30, 2018
1 parent f97e899 commit 7ec04b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib-master/master-login.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/util/script-login.c
Expand Up @@ -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);
Expand Down

0 comments on commit 7ec04b0

Please sign in to comment.