erofs-utils: lib: actually skip the unidentified xattrs
authorSandeep Dhavale <dhavale@google.com>
Tue, 20 Aug 2024 21:01:23 +0000 (14:01 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 21 Aug 2024 03:47:28 +0000 (11:47 +0800)
parse_one_xattr() will return null if it detects unidentified xattr.
In such cases we need to skip this xattr which was our intention than
try to add it in erofs_xattr_add() which results in null pointer
dereference.

Fixes: 3037f8958f3b ("erofs-utils: skip all unidentified xattrs from local paths")
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20240820210123.2684886-2-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/xattr.c

index 651657f979cc65f4b4c3e619583020795341ffc5..9f31f2d0a7d7d20da12d10d883b9332155e9cd1c 100644 (file)
@@ -448,6 +448,9 @@ static int read_xattrs_from_file(const char *path, mode_t mode,
                        ret = PTR_ERR(item);
                        goto err;
                }
+               /* skip unidentified xattrs */
+               if (!item)
+                       continue;
 
                ret = erofs_xattr_add(ixattrs, item);
                if (ret < 0)