diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index 417e8650e5..6128b1b68d 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -295,7 +295,7 @@ int xsetxattr_full( assert(fd >= 0 || fd == AT_FDCWD); assert((at_flags & ~(AT_SYMLINK_FOLLOW|AT_EMPTY_PATH)) == 0); assert(name); - assert(value); + assert(value || size == 0); if (size == SIZE_MAX) size = strlen(value); diff --git a/src/test/test-xattr-util.c b/src/test/test-xattr-util.c index 4d39a0a1f1..5dda7be696 100644 --- a/src/test/test-xattr-util.c +++ b/src/test/test-xattr-util.c @@ -159,6 +159,10 @@ TEST(xsetxattr) { ASSERT_OK(xsetxattr_full(dfd, "test", 0, "user.foo", "dirfd", SIZE_MAX, XATTR_REPLACE)); verify_xattr(dfd, "dirfd"); + /* Empty xattr values are allowed */ + ASSERT_OK(xsetxattr_full(dfd, "test", 0, "user.foo", NULL, 0, 0)); + verify_xattr(dfd, ""); + /* by fd (O_PATH) */ ASSERT_OK_ERRNO(fd = openat(dfd, "test", O_PATH|O_CLOEXEC));