From afa793ff16b349989ca7c958466eae15d2d003f9 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Tue, 12 May 2015 16:36:55 +0530 Subject: libgfapi: Gracefully exit when glfd is invalid When glfs_* methods operating on glfd are invoked after calling glfs_close(), the program segfaults inside __GLFS_ENTRY_VALIDATE_FD trying to deference glfd->fd->inode which is invalid. Also, returning EBADF seemed more specific than EINVAL. BUG: 1221008 Change-Id: I13a92dca52da9a300252b69e026581b3a9e931fd Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/10759 Tested-by: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- api/src/glfs-internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'api/src/glfs-internal.h') diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h index 3f8ac92ac7e..ff8ace9cbb8 100644 --- a/api/src/glfs-internal.h +++ b/api/src/glfs-internal.h @@ -268,8 +268,8 @@ do { \ #define __GLFS_ENTRY_VALIDATE_FD(glfd, label) \ do { \ - if (!glfd) { \ - errno = EINVAL; \ + if (!glfd || !glfd->fd || !glfd->fd->inode) { \ + errno = EBADF; \ goto label; \ } \ old_THIS = THIS; \ -- cgit