Linux-EROFS Archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows
Date: Thu, 11 Apr 2024 18:00:39 +0800	[thread overview]
Message-ID: <20240411100039.197417-1-hsiangkao@linux.alibaba.com> (raw)

Otherwise, large files won't be imported properly.

Fixes: e3dfe4b8db26 ("erofs-utils: mkfs: support tgz streams for tarerofs")
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 lib/tar.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/tar.c b/lib/tar.c
index b45657d..8d606f9 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -233,7 +233,7 @@ int erofs_iostream_read(struct erofs_iostream *ios, void **buf, u64 bytes)
 					  ret, erofs_strerror(-errno));
 	}
 	*buf = ios->buffer;
-	ret = min_t(int, ios->tail, bytes);
+	ret = min_t(int, ios->tail, min_t(u64, bytes, INT_MAX));
 	ios->head = ret;
 	return ret;
 }
@@ -605,10 +605,9 @@ void tarerofs_remove_inode(struct erofs_inode *inode)
 static int tarerofs_write_file_data(struct erofs_inode *inode,
 				    struct erofs_tarfile *tar)
 {
-	unsigned int j;
 	void *buf;
 	int fd, nread;
-	u64 off;
+	u64 off, j;
 
 	if (!inode->i_diskbuf) {
 		inode->i_diskbuf = calloc(1, sizeof(*inode->i_diskbuf));
-- 
2.39.3


             reply	other threads:[~2024-04-11 10:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 10:00 Gao Xiang [this message]
2024-04-11 11:10 ` [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows Jingbo Xu
2024-04-11 18:00 ` Sandeep Dhavale via Linux-erofs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240411100039.197417-1-hsiangkao@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).