From 95baae3390157f753fcf07603bd8247095ccab38 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 9 Feb 2004 02:58:33 -0800 Subject: [PATCH] [PATCH] getxattr error checking fix From: Nathan Scott , Andreas Gruenbacher XFS regression tests tripped a couple of problems with the recent xattr fix. When a size of 0 is passed in, the getxattr and listxattr syscalls return the size that would be required for the value or list of names, without actually returning the value. The previous patch accidentally removed this test, and so querying the required size broke. --- fs/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index 10adae3f722e5..24bd5427d4f4d 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -140,7 +140,7 @@ getxattr(struct dentry *d, char __user *name, void __user *value, size_t size) goto out; error = d->d_inode->i_op->getxattr(d, kname, kvalue, size); if (error > 0) { - if (copy_to_user(value, kvalue, error)) + if (size && copy_to_user(value, kvalue, error)) error = -EFAULT; } else if (error == -ERANGE && size >= XATTR_SIZE_MAX) { /* The file system tried to returned a value bigger @@ -222,7 +222,7 @@ listxattr(struct dentry *d, char __user *list, size_t size) goto out; error = d->d_inode->i_op->listxattr(d, klist, size); if (error > 0) { - if (copy_to_user(list, klist, error)) + if (size && copy_to_user(list, klist, error)) error = -EFAULT; } else if (error == -ERANGE && size >= XATTR_LIST_MAX) { /* The file system tried to returned a list bigger -- 2.53.0