diff options
author | Richard Jones <rjones@redhat.com> | 2010-05-07 13:30:42 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-05-07 15:27:29 +0100 |
commit | 42f59b28f123f53ae038df23a9abee08e959e46b (patch) | |
tree | 4ac2c3ac492680659fffde3b4316703c74953bcd /src | |
parent | a84f1360499309e2d2ecb661adc6917539b5eef4 (diff) | |
download | libguestfs-42f59b28f123f53ae038df23a9abee08e959e46b.tar.gz libguestfs-42f59b28f123f53ae038df23a9abee08e959e46b.tar.xz libguestfs-42f59b28f123f53ae038df23a9abee08e959e46b.zip |
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.
Diffstat (limited to 'src')
-rwxr-xr-x | src/generator.ml | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/generator.ml b/src/generator.ml index 1e6d3c0d..c01e265b 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3287,7 +3287,20 @@ for full details."); ("read_file", (RBufferOut "content", [Pathname "path"]), 150, [ProtocolLimitWarning], [InitISOFS, Always, TestOutputBuffer ( - [["read_file"; "/known-4"]], "abc\ndef\nghi")], + [["read_file"; "/known-4"]], "abc\ndef\nghi"); + (* Test various near large, large and too large files (RHBZ#589039). *) + InitBasicFS, Always, TestLastFail ( + [["touch"; "/a"]; + ["truncate_size"; "/a"; "4194303"]; (* GUESTFS_MESSAGE_MAX - 1 *) + ["read_file"; "/a"]]); + InitBasicFS, Always, TestLastFail ( + [["touch"; "/a"]; + ["truncate_size"; "/a"; "4194304"]; (* GUESTFS_MESSAGE_MAX *) + ["read_file"; "/a"]]); + InitBasicFS, Always, TestLastFail ( + [["touch"; "/a"]; + ["truncate_size"; "/a"; "41943040"]; (* GUESTFS_MESSAGE_MAX * 10 *) + ["read_file"; "/a"]])], "read a file", "\ This calls returns the contents of the file C<path> as a |