summaryrefslogtreecommitdiffstats
path: root/api
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:46:28 -0700
commitcc477c7da1b543d51939aba919155a651099d4ba (patch)
treed582b3cfc9a2c8232f073ff251a79ae17e12229c /api
parent878bc03d7df8e18faca13fbf89a7ae55a29b0fdc (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/5237 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')
-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 66e7d69f14d..7cb442b5f60 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;
}