qrexec: added two I/O error checks, even though it is redundant in these cases

This commit is contained in:
Rafal Wojtczuk 2011-05-04 12:56:52 +02:00
parent d68183da0c
commit b4fb7a4b5d
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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;