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, 14 May 2010 16:06:06 +0000 (17:06 +0100)
commit988a707f3731e4174582e74fc83c30d89c5afb7e
tree7119a7453b3ff16d51c41f6d809c0da936f0f0f2
parenta57f15a0c434797c45b334f9ace5f18a3bef610a
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.
(cherry picked from commit 42f59b28f123f53ae038df23a9abee08e959e46b)
daemon/file.c
daemon/initrd.c
src/generator.ml