diff options
author | Jeff Mahoney <jeffm@suse.com> | 2017-07-24 21:29:39 -0400 |
---|---|---|
committer | Jeff Mahoney <jeffm@suse.com> | 2017-07-25 09:19:10 -0400 |
commit | 5df19dee468ce7c4cab6293adad30009081ec95d (patch) | |
tree | 935e5c17041ad98cb4e40d5412d7ebab328413ea | |
parent | b1e32aaa568b45a1a5e5cdaf23d0ffdc947fcd11 (diff) | |
download | reiserfsprogs-5df19dee468ce7c4cab6293adad30009081ec95d.tar.gz |
xattrs: handle both hash forms in reiserfs_check_xattr
It turns out that the csum_partial used on x86_64 is essentially the only
implementation that is 32-bit and it's intended to be folded. Other
implementations use a 16-bit version. This library includes the 16-bit
version so that any validation of extended attribute checksums would
fail. The fix is to convert the 32-bit version to the 16-bit version
if the 16-bit version fails before trying again.
This affects moving file systems between architectures that define
csum_partial differently.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
-rw-r--r-- | reiserfscore/xattr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/reiserfscore/xattr.c b/reiserfscore/xattr.c index 8ad81f3..56c0f60 100644 --- a/reiserfscore/xattr.c +++ b/reiserfscore/xattr.c @@ -84,19 +84,19 @@ inline __u32 reiserfs_xattr_hash(const char *msg, int len) return csum_partial(msg, len, 0); } - int reiserfs_check_xattr(const void *body, int len) { const struct reiserfs_xattr_header *xah = body; int hdrsz = sizeof(struct reiserfs_xattr_header); - __u32 hash; + __u32 hash, disk_hash; if (len < hdrsz) return -EINVAL; hash = reiserfs_xattr_hash(body + hdrsz, len - hdrsz); + disk_hash = le32_to_cpu(xah->h_hash); return xah->h_magic == cpu_to_le32(REISERFS_XATTR_MAGIC) && - le32_to_cpu(xah->h_hash) == hash; + (disk_hash == hash || from32to16(disk_hash) == hash); } int reiserfs_acl_count(size_t size) |