erofs: fix compression fallback in tarerofs mode
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 27 Mar 2024 00:46:14 +0000 (08:46 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Sun, 7 Apr 2024 07:36:01 +0000 (15:36 +0800)
The return value of `lseek(fd, fpos, SEEK_SET)` can overflow the `int`
type.  Fix this.

Fixes: 376fb2dbe66d ("erofs-utils: lib: introduce diskbuf")
Link: https://lore.kernel.org/r/20240327004614.1465889-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/inode.c

index 4c29aa7619a402deb074a162de61c4f4dc2674f8..ba0419f52a595b90373ea1e0cb86394a7ce3adb3 100644 (file)
@@ -497,8 +497,7 @@ int erofs_write_file(struct erofs_inode *inode, int fd, u64 fpos)
                if (!ret || ret != -ENOSPC)
                        return ret;
 
-               ret = lseek(fd, fpos, SEEK_SET);
-               if (ret < 0)
+               if (lseek(fd, fpos, SEEK_SET) < 0)
                        return -errno;
        }