diff --git a/qrexec/qrexec_daemon.c b/qrexec/qrexec_daemon.c index 7d522067..a5d2bdc6 100644 --- a/qrexec/qrexec_daemon.c +++ b/qrexec/qrexec_daemon.c @@ -98,6 +98,11 @@ void init(int xid) umask(0007); // make the log readable by the "qubes" group logfd = open(qrexec_error_log_name, O_WRONLY | O_CREAT | O_TRUNC, 0640); + if (logfd < 0) { + perror("open"); + exit(1); + } + dup2(logfd, 1); dup2(logfd, 2); diff --git a/qrexec/write_stdin.c b/qrexec/write_stdin.c index e77ccf55..7ace53b6 100644 --- a/qrexec/write_stdin.c +++ b/qrexec/write_stdin.c @@ -49,7 +49,10 @@ int flush_client_data(int fd, int client_id, struct buffer *buffer) } else return WRITE_STDIN_BUFFERED; } - buffer_remove(buffer, len); + // we previously called buffer_remove(buffer, len) + // it will be wrong if we change MAX_DATA_CHUNK to something large + // as pipes writes are atomic only to PIPE_MAX limit + buffer_remove(buffer, ret); len = buffer_len(buffer); if (!len) { struct server_header s_hdr;