]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: fix boundary test in xfs_attr_shortform_verify
authorEric Sandeen <sandeen@redhat.com>
Tue, 15 Sep 2020 19:59:38 +0000 (15:59 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Tue, 15 Sep 2020 19:59:38 +0000 (15:59 -0400)
commitbe2f3d3984902d7ce1e30fc7ec745f7671b7ffdd
tree8cf2f4c67a7a3139c1d37575ff8bd927c0d695a9
parentd6e8deb14cbea11d8f265537f7163428717b93fb
xfs: fix boundary test in xfs_attr_shortform_verify

Source kernel commit: f4020438fab05364018c91f7e02ebdd192085933

The boundary test for the fixed-offset parts of xfs_attr_sf_entry in
xfs_attr_shortform_verify is off by one, because the variable array
at the end is defined as nameval[1] not nameval[].
Hence we need to subtract 1 from the calculation.

This can be shown by:

# touch file
# setfattr -n root.a file

and verifications will fail when it's written to disk.

This only matters for a last attribute which has a single-byte name
and no value, otherwise the combination of namelen & valuelen will
push endp further out and this test won't fail.

Fixes: 1e1bbd8e7ee06 ("xfs: create structure verifier function for shortform xattrs")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr_leaf.c