don't write more than PIPE_BUF bytes in any one write() in io.c
[rsync/rsync.git] / io.c
diff --git a/io.c b/io.c
index 9e2d379..9e2a475 100644 (file)
--- a/io.c
+++ b/io.c
@@ -361,8 +361,11 @@ static void writefd_unbuffered(int fd,char *buf,int len)
                }
 
                if (FD_ISSET(fd, &w_fds)) {
-                       int n = len-total;
-                       int ret = write(fd,buf+total,n?n:1);
+                       int ret, n = len-total;
+                       
+                       if (n > PIPE_BUF) n = PIPE_BUF;
+
+                       ret = write(fd,buf+total,n?n:1);
 
                        if (ret == -1 && errno == EINTR) {
                                continue;