[PATCH] erofs: fix compression fallback in tarerofs mode

Gao Xiang hsiangkao at linux.alibaba.com
Wed Mar 27 11:46:14 AEDT 2024


The return value of `lseek(fd, fpos, SEEK_SET)` can overflow the `int`
type.  Fix this.

Fixes: 376fb2dbe66d ("erofs-utils: lib: introduce diskbuf")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 4c29aa7..ba0419f 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -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;
 	}
 
-- 
2.39.3



More information about the Linux-erofs mailing list