[PATCH] erofs-utils: lib: fix tarerofs 32-bit overflows

Jingbo Xu jefflexu at linux.alibaba.com
Thu Apr 11 21:10:09 AEST 2024



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 at linux.alibaba.com>


LGTM.

Reviewed-by: Jingbo Xu <jefflexu at 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


More information about the Linux-erofs mailing list