[PATCH] erofs-utils: tar: fix multi-chunk metadata reads
Ajay Rajera
newajay.11r at gmail.com
Sat Mar 28 11:57:35 AEDT 2026
Tested-by: Ajay Rajera <newajay.11r at gmail.com>
(Tested with long PAX headers via mkfs.erofs --tar)
On Thu, 26 Mar 2026 at 16:03, Vansh Choudhary <ch at vnsh.in> wrote:
>
> Advance the destination buffer in erofs_iostream_bread() after each
> erofs_iostream_read() call.
>
> Without that, metadata reads that span multiple stream chunks keep
> overwriting the start of the output buffer, which can corrupt PAX
> headers, GNU long names, long links, and other buffered metadata.
>
> Signed-off-by: Vansh Choudhary <ch at vnsh.in>
> ---
> lib/tar.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/tar.c b/lib/tar.c
> index 70bf091..77754fd 100644
> --- a/lib/tar.c
> +++ b/lib/tar.c
> @@ -250,6 +250,7 @@ int erofs_iostream_read(struct erofs_iostream *ios, void **buf, u64 bytes)
> int erofs_iostream_bread(struct erofs_iostream *ios, void *buf, u64 bytes)
> {
> u64 rem = bytes;
> + u8 *dst = buf;
> void *src;
> int ret;
>
> @@ -257,7 +258,8 @@ int erofs_iostream_bread(struct erofs_iostream *ios, void *buf, u64 bytes)
> ret = erofs_iostream_read(ios, &src, rem);
> if (ret < 0)
> return ret;
> - memcpy(buf, src, ret);
> + memcpy(dst, src, ret);
> + dst += ret;
> rem -= ret;
> } while (rem && ret);
>
> --
> 2.43.0
>
>
More information about the Linux-erofs
mailing list