diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/src/glfs-fops.c | 10 | ||||
-rw-r--r-- | api/src/glfs-handleops.c | 9 |
2 files changed, 15 insertions, 4 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index 535dad3fea1..bc9c758a9c9 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -2568,11 +2568,14 @@ glfs_listxattr_process (void *value, size_t size, dict_t *xattr) { int ret = -1; - if (!value || !size || !xattr) + if (!xattr) goto out; ret = dict_keys_join (NULL, 0, xattr, NULL); + if (!value || !size) + goto out; + if (size < ret) { ret = -1; errno = ERANGE; @@ -2580,9 +2583,10 @@ glfs_listxattr_process (void *value, size_t size, dict_t *xattr) dict_keys_join (value, size, xattr, NULL); } - dict_unref (xattr); - out: + if (xattr) + dict_unref (xattr); + return ret; } diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index e3df8c00b1a..ba468382077 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -15,6 +15,9 @@ #include "glfs.h" #include "glfs-handles.h" +int +glfs_listxattr_process (void *value, size_t size, dict_t *xattr); + static void glfs_iatt_from_stat (struct stat *stat, int valid, struct iatt *iatt, int *glvalid) @@ -259,7 +262,11 @@ glfs_h_getxattrs (struct glfs *fs, struct glfs_object *object, const char *name, if (ret) goto out; - ret = glfs_getxattr_process (value, size, xattr, name); + /* If @name is NULL, means get all the xattrs (i.e listxattr). */ + if (name) + ret = glfs_getxattr_process (value, size, xattr, name); + else + ret = glfs_listxattr_process (value, size, xattr); out: loc_wipe (&loc); |