Skip to content

Commit

Permalink
Merge pull request #400 from cgwalters/validate-xattr-key-nonempty
Browse files Browse the repository at this point in the history
writer: Reject empty xattr names
  • Loading branch information
cgwalters authored Dec 2, 2024
2 parents d62aec4 + 02077e8 commit c861efa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/assets/should-fail-empty-xattr-key.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/ 4096 40555 2 0 0 0 1633950376.0 - - -
/noxattr-key 0 100644 1 0 0 0 0.0 - - - =somevalue
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit c861efa

Please sign in to comment.