From 0bc54f3ea7a56040df4a67b8626200b47fa3d779 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Mon, 22 Feb 2016 16:50:12 +0530 Subject: gfapi : fixing listxattr call for handle ops Currently listxattr is called as part of glfs_h_getxattrs() when NULL is passed to name field, but glfs_h_getxattrs_common() inside it will error out if name is NULL. Therefore listxattr is broken for handle ops. Change-Id: I9ced6e33525e1e1a50298972e4922c954fc2b223 BUG: 1310620 Signed-off-by: Jiffin Tony Thottan Reviewed-on: http://review.gluster.org/13482 Reviewed-by: Niels de Vos Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- api/src/glfs-handleops.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'api') diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index a135f77883e..f700f1a6808 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -313,7 +313,8 @@ GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_getattrs, 3.4.2); int glfs_h_getxattrs_common (struct glfs *fs, struct glfs_object *object, - dict_t **xattr, const char *name) + dict_t **xattr, const char *name, + gf_boolean_t is_listxattr) { int ret = 0; xlator_t *subvol = NULL; @@ -326,16 +327,17 @@ glfs_h_getxattrs_common (struct glfs *fs, struct glfs_object *object, return -1; } - if (!name || *name == '\0') { - errno = EINVAL; - return -1; - } + if (!is_listxattr) { + if (!name || *name == '\0') { + errno = EINVAL; + return -1; + } - if (strlen(name) > GF_XATTR_NAME_MAX) { - errno = ENAMETOOLONG; - return -1; + if (strlen(name) > GF_XATTR_NAME_MAX) { + errno = ENAMETOOLONG; + return -1; + } } - /* get the active volume */ subvol = glfs_active_subvol (fs); if (!subvol) { @@ -385,7 +387,8 @@ pub_glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object, DECLARE_OLD_THIS; __GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs); - ret = glfs_h_getxattrs_common (fs, object, &xattr, name); + ret = glfs_h_getxattrs_common (fs, object, &xattr, name, + (name == NULL)); if (ret) goto out; @@ -2092,7 +2095,8 @@ pub_glfs_h_acl_get (struct glfs *fs, struct glfs_object *object, } else new_object = object; - ret = glfs_h_getxattrs_common (fs, new_object, &xattr, acl_key); + ret = glfs_h_getxattrs_common (fs, new_object, &xattr, acl_key, + _gf_false); if (ret) goto out; -- cgit