From dd8f1a544d5c98277d42ecace4dad854c428b262 Mon Sep 17 00:00:00 2001 From: Sidharth Anupkrishnan Date: Mon, 6 Jul 2020 14:45:46 +0530 Subject: [PATCH] client: Fix setxattr with 0 size specified When xattrs are set with 0 size, the value should be set to an empty string. Signed-off-by: Sidharth Anupkrishnan --- src/client/Client.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index c2129b01652b7..6aa7d3fc2cb30 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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); -- 2.39.5