]> git.hungrycats.org Git - linux/commitdiff
[PATCH] getxattr error checking fix
authorAndrew Morton <akpm@osdl.org>
Mon, 9 Feb 2004 10:58:33 +0000 (02:58 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 9 Feb 2004 10:58:33 +0000 (02:58 -0800)
From: Nathan Scott <nathans@sgi.com>,
      Andreas Gruenbacher <agruen@suse.de>

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

index 10adae3f722e53b0524438c664b6a4de440955b6..24bd5427d4f4d2be2a0095a62095165de826ec80 100644 (file)
@@ -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