]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix setxattr with 0 size specified 36173/head
authorSidharth Anupkrishnan <sanupkri@redhat.com>
Mon, 6 Jul 2020 09:15:46 +0000 (14:45 +0530)
committerNathan Cutler <ncutler@suse.com>
Sat, 18 Jul 2020 15:43:00 +0000 (17:43 +0200)
When xattrs are set with 0 size, the value should be set to an empty string.
Signed-off-by: Sidharth Anupkrishnan <sanupkri@redhat.com>
(cherry picked from commit dd8f1a544d5c98277d42ecace4dad854c428b262)

src/client/Client.cc

index 3a02b72c2ba2903bcabbc392709a594aef68787a..576a6d2fcf583f79281786d8ec9619c3a542fd33 100644 (file)
@@ -11538,6 +11538,12 @@ int Client::_setxattr(Inode *in, const char *name, const void *value,
     return -EROFS;
   }
 
+  if (size == 0) {
+    value = "";
+  } else if (value == NULL) {
+      return -EINVAL;
+  }
+
   bool posix_acl_xattr = false;
   if (acl_type == POSIX_ACL)
     posix_acl_xattr = !strncmp(name, "system.", 7);