summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-11-17 17:02:45 +0000
committerRichard Jones <rjones@redhat.com>2009-11-17 20:14:47 +0000
commit336275ee6dbff5efa2152a4f67ef354b81d15d59 (patch)
tree742c3905a6d4332964ad9950f6c615d40cdc6354
parent3fc9951016d08e2467375e24094a468713637c1f (diff)
downloadlibguestfs-336275ee6dbff5efa2152a4f67ef354b81d15d59.tar.gz
libguestfs-336275ee6dbff5efa2152a4f67ef354b81d15d59.tar.xz
libguestfs-336275ee6dbff5efa2152a4f67ef354b81d15d59.zip
fuse: Fix read for empty files.
Error handling for the guestfs_pread call was incorrect, which meant that empty files could produce spurious error messages.
-rw-r--r--fuse/guestmount.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index baf2b667..ba0d626c 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -620,8 +620,14 @@ fg_read (const char *path, char *buf, size_t size, off_t offset,
if (size > limit)
size = limit;
+ /* Note the correct error handling here is tricky, because in the
+ * case where the call returns a zero-length buffer, it might return
+ * NULL. However it won't adjust rsize along the error path, so we
+ * can set rsize to something beforehand and use that as a flag.
+ */
+ rsize = 1;
r = guestfs_pread (g, path, size, offset, &rsize);
- if (r == NULL)
+ if (rsize == 1 && r == NULL)
return error ();
/* This should never happen, but at least it stops us overflowing