* [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows
@ 2024-04-11 10:00 Gao Xiang
2024-04-11 11:10 ` Jingbo Xu
2024-04-11 18:00 ` Sandeep Dhavale via Linux-erofs
0 siblings, 2 replies; 3+ messages in thread
From: Gao Xiang @ 2024-04-11 10:00 UTC (permalink / raw)
To: linux-erofs; +Cc: Gao Xiang
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows
2024-04-11 10:00 [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows Gao Xiang
@ 2024-04-11 11:10 ` Jingbo Xu
2024-04-11 18:00 ` Sandeep Dhavale via Linux-erofs
1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2024-04-11 11:10 UTC (permalink / raw)
To: Gao Xiang, linux-erofs
On 4/11/24 6:00 PM, Gao Xiang wrote:
> 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>
LGTM.
Reviewed-by: Jingbo Xu <jefflexu@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));
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows
2024-04-11 10:00 [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows Gao Xiang
2024-04-11 11:10 ` Jingbo Xu
@ 2024-04-11 18:00 ` Sandeep Dhavale via Linux-erofs
1 sibling, 0 replies; 3+ messages in thread
From: Sandeep Dhavale via Linux-erofs @ 2024-04-11 18:00 UTC (permalink / raw)
To: Gao Xiang; +Cc: linux-erofs
Looks good.
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Thanks,
Sandeep.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-11 18:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11 10:00 [PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows Gao Xiang
2024-04-11 11:10 ` Jingbo Xu
2024-04-11 18:00 ` Sandeep Dhavale via Linux-erofs
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 NNTP newsgroup(s).