daemon: Fix read-file so it fails gracefully for large files (RHBZ#589039).
authorRichard Jones <rjones@redhat.com>
Fri, 7 May 2010 12:30:42 +0000 (13:30 +0100)
committerRichard Jones <rjones@redhat.com>
Fri, 7 May 2010 14:27:29 +0000 (15:27 +0100)
commit42f59b28f123f53ae038df23a9abee08e959e46b
tree4ac2c3ac492680659fffde3b4316703c74953bcd
parenta84f1360499309e2d2ecb661adc6917539b5eef4
daemon: Fix read-file so it fails gracefully for large files (RHBZ#589039).

Pengzhen Cao noticed that read-file would fail for files
larger than the protocol size; this is *not* the bug.  However
it would also lose protocol synchronization after this.

The reason was that functions which return RBufferOut in the
generator must not 'touch' the *size_r parameter along error
return paths.

I fixed read-file and initrd-cat, and I checked that pread was
doing the right thing.

This also adds regression tests for read-file with various categories
of large file.
daemon/file.c
daemon/initrd.c
src/generator.ml