diff --git a/libcomposefs/lcfs-writer.c b/libcomposefs/lcfs-writer.c index f6e202e6..6e675b0a 100644 --- a/libcomposefs/lcfs-writer.c +++ b/libcomposefs/lcfs-writer.c @@ -1691,7 +1691,7 @@ int lcfs_node_set_xattr_internal(struct lcfs_node_s *node, const char *name, char *k, *v; const size_t namelen = strlen(name); - if (namelen > XATTR_NAME_MAX) { + if (namelen == 0 || namelen > XATTR_NAME_MAX) { errno = ERANGE; return -1; } diff --git a/tests/assets/should-fail-empty-xattr-key.dump b/tests/assets/should-fail-empty-xattr-key.dump new file mode 100644 index 00000000..52a9d7d7 --- /dev/null +++ b/tests/assets/should-fail-empty-xattr-key.dump @@ -0,0 +1,2 @@ +/ 4096 40555 2 0 0 0 1633950376.0 - - - +/noxattr-key 0 100644 1 0 0 0 0.0 - - - =somevalue diff --git a/tests/meson.build b/tests/meson.build index 58f98750..30277c4e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -21,6 +21,7 @@ test_assets_small_extra = [ test_assets_should_fail = [ 'should-fail-long-link.dump', + 'should-fail-empty-xattr-key.dump', 'should-fail-long-xattr-key.dump', 'should-fail-long-xattr-value.dump', 'should-fail-honggfuzz-long-xattr.dump',