[PATCH] erofs-utils: tar: fix multi-chunk metadata reads
Vansh Choudhary
ch at vnsh.in
Thu Mar 26 21:32:54 AEDT 2026
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