public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: tar: fix multi-chunk metadata reads
@ 2026-03-26 10:32 Vansh Choudhary
  2026-03-28  0:57 ` Ajay Rajera
  2026-03-28  1:19 ` Nithurshen
  0 siblings, 2 replies; 3+ messages in thread
From: Vansh Choudhary @ 2026-03-26 10:32 UTC (permalink / raw)
  To: linux-erofs; +Cc: Vansh Choudhary

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@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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-28  1:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 10:32 [PATCH] erofs-utils: tar: fix multi-chunk metadata reads Vansh Choudhary
2026-03-28  0:57 ` Ajay Rajera
2026-03-28  1:19 ` Nithurshen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox