summaryrefslogtreecommitdiffstats
path: root/api/src
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-06-16 06:19:52 -0700
committerVijay Bellur <vbellur@redhat.com>2013-06-20 01:45:50 -0700
commitd7e80787fc61a4fe9e72ff80565dc720ac29441a (patch)
treedb86c0bd03339b5265b7c6da1e6ed025d5c61812 /api/src
parentcc9ca7d2b2f5c91d80265c28ca724cb233c2bd77 (diff)
gfapi: fix read past EOF in glfs_preadv()
When syncop_preadv() returns 0, we are returning @size as-is (without modifying user passed buffer). This results in junk data being read when read offset is at or beyond EOF. Change-Id: I8aa9c957359f9a52833b944b452f501b6f5538d3 BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5236 Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: José Rivera <jrivera@redhat.com> Tested-by: José Rivera <jrivera@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api/src')
-rw-r--r--api/src/glfs-fops.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index e30a3548ad0..fee97abda1d 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -451,8 +451,8 @@ glfs_preadv (struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
off_t offset, int flags)
{
xlator_t *subvol = NULL;
- int ret = -1;
- size_t size = -1;
+ ssize_t ret = -1;
+ ssize_t size = -1;
struct iovec *iov = NULL;
int cnt = 0;
struct iobref *iobref = NULL;
@@ -489,13 +489,14 @@ glfs_preadv (struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
if (iobref)
iobref_unref (iobref);
+ ret = size;
out:
if (fd)
fd_unref (fd);
glfs_subvol_done (glfd->fs, subvol);
- return size;
+ return ret;
}