]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix virPipeReadUntilEOF on more than 1024 bytes of data
authorDaniel Veillard <veillard@redhat.com>
Wed, 3 Nov 2010 07:43:43 +0000 (08:43 +0100)
committerDaniel Veillard <veillard@redhat.com>
Wed, 3 Nov 2010 07:43:43 +0000 (08:43 +0100)
virPipeReadUntilEOF is used to read the stdout of exec'ed
and this could fail to capture the full output and read only
1024 bytes.
  The problem is that this is based on a poll loop, and in the
loop we read at most 1024 bytes per file descriptor, but we also
note in the loop if poll indicates that the process won't output
more than that on that fd by setting finished[i] = 1.
  The simplest way is that if we read a full buffer make sure
finished[i] is still 0 because we will need another pass in the
loop.

src/util/util.c

index f7c7d3253ce8b0b632f2f447206a7f85109c7fdf..a05967514047823f16982b9e8f3d986d29307368 100644 (file)
@@ -984,6 +984,9 @@ virPipeReadUntilEOF(int outfd, int errfd,
 
             got = read(fds[i].fd, data, sizeof(data));
 
+            if (got == sizeof(data))
+                finished[i] = 0;
+
             if (got == 0) {
                 finished[i] = 1;
                 continue;