Commit 0a218854 by Dwight Engen Committed by Stéphane Graber

fortify: check the value returned from write(2)

Also check that we wrote the amount we expected to. The write on the pty is blocking but we could still get a short write on EINTR, so we should SYSERROR it. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 03027ad9
......@@ -165,14 +165,18 @@ static int master_handler(int fd, void *data, struct lxc_epoll_descr *descr)
{
char buf[1024];
int *peer = (int *)data;
int r;
int r,w;
r = read(fd, buf, sizeof(buf));
if (r < 0) {
SYSERROR("failed to read");
return 1;
}
r = write(*peer, buf, r);
w = write(*peer, buf, r);
if (w < 0 || w != r) {
SYSERROR("failed to write");
return 1;
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment