From c74f6f85eda50632c105f1fdb6308c90fdac8c46 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 25 Sep 2026 12:00:28 +0200 Subject: [PATCH] fix(xattr): Handle labels without value I stumbled over this with the very first image I tried: > sudo systemd-pull oci --system quay.io/toolbx/arch-toolbox:latest That failed with a label "user.overlay.origin" with a value of NULL and size 0. This one-line change allows value == NULL if size == 0 when setting xattrs. (cherry picked from commit 885fe07ee37cff7316680b5088d11081e01813b1) --- src/basic/xattr-util.c | 2 +- src/test/test-xattr-util.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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));