core: Always sort incoming xattrs
authorColin Walters <walters@verbum.org>
Wed, 27 Nov 2024 02:15:23 +0000 (21:15 -0500)
committerColin Walters <walters@verbum.org>
Mon, 2 Dec 2024 15:40:17 +0000 (10:40 -0500)
commit1858d3d300bf12907a13335f616654f422cdaa58
tree50ee360d0e022eb5d6ee265d2bfb38e60d844656
parent295841b472d583eb6f449c1bdefbab5c9a7de5a3
core: Always sort incoming xattrs

When recomputing selinux attrs during commit, we weren't sorting,
which could cause various issues like fsck failures.

This is a big hammer; change things so we always canonicalize
(i.e. sort) the incoming xattrs when creating a file header
and directory metadata.

I think almost all places in the code were already keeping
things sorted, but it's better to ensure correctness first.
If we ever have some performance issue (I'm doubtful) we
could add something like `_ostree_file_header_known_canonicalized`
or so.

Closes: https://github.com/ostreedev/ostree/issues/3343
Signed-off-by: Colin Walters <walters@verbum.org>
src/libostree/ostree-core.c
tests/test-basic-c.c