erofs-utils: lib: fix sorting shared xattrs
authorSheng Yong <shengyong@oppo.com>
Fri, 13 Sep 2024 14:35:42 +0000 (22:35 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Sat, 14 Sep 2024 12:13:39 +0000 (20:13 +0800)
commitc9d13cee3f5b255a9d2030e62c6c910c956f6f75
tree769c5a2c2ad38199c98afeeefdda8368b6c3815c
parent5c56672ae203a4382bc337022a69e490289a83cf
erofs-utils: lib: fix sorting shared xattrs

The length of xattr_item->kvbuf is calculated by EROFS_XATTR_KVSIZE,
and the key part has a trailing '\0' before the value part. When qsort
compares two xattr_items, the key-value length should be calculated by
EROFS_XATTR_KVSIZE, and use memcmp instead of strncmp to avoid key-value
string being cut by '\0'.

Fixes: 5df285cf405d ("erofs-utils: lib: refactor extended attribute name prefixes")
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240913143542.3265071-1-shengyong@oppo.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/xattr.c