From cc477c7da1b543d51939aba919155a651099d4ba Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Sun, 16 Jun 2013 06:19:52 -0700 Subject: gfapi: fix read past EOF in glfs_preadv() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: http://review.gluster.org/5237 Reviewed-by: Raghavendra Talur Reviewed-by: José Rivera Tested-by: José Rivera Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- api/src/glfs-fops.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'api/src/glfs-fops.c') 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; } -- cgit