ceph: don't null-terminate xattr values
authorAlex Elder <elder@dreamhost.com>
Mon, 23 Jan 2012 21:49:27 +0000 (15:49 -0600)
committerAlex Elder <elder@dreamhost.com>
Thu, 22 Mar 2012 15:47:46 +0000 (10:47 -0500)
For some reason, ceph_setxattr() allocates an extra byte in which a
'\0' is stored past the end of an extended attribute value.  This is
not needed, and is potentially misleading, so get rid of it.

Signed-off-by: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/xattr.c

index a76f697..bfff735 100644 (file)
@@ -730,11 +730,9 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
                goto out;
 
        if (val_len) {
-               newval = kmalloc(val_len + 1, GFP_NOFS);
+               newval = kmemdup(value, val_len, GFP_NOFS);
                if (!newval)
                        goto out;
-               memcpy(newval, value, val_len);
-               newval[val_len] = '\0';
        }
 
        xattr = kmalloc(sizeof(struct ceph_inode_xattr), GFP_NOFS);