]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix setxattr with 0 size specified 35725/head
authorSidharth Anupkrishnan <sanupkri@redhat.com>
Mon, 6 Jul 2020 09:15:46 +0000 (14:45 +0530)
committerSidharth Anupkrishnan <sanupkri@redhat.com>
Mon, 6 Jul 2020 09:15:50 +0000 (14:45 +0530)
When xattrs are set with 0 size, the value should be set to an empty string.
Signed-off-by: Sidharth Anupkrishnan <sanupkri@redhat.com>
src/client/Client.cc

index c2129b01652b7221b1c7f6802158a4c17bb5d662..6aa7d3fc2cb3070fd01f65b63cdcce02da8c3fda 100644 (file)
@@ -11619,6 +11619,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);