From 2867264662e184c5b258a3e1280af334ace75ecf Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Wed, 8 Oct 2025 19:55:54 +0100 Subject: [PATCH] Reader: fill the buffer passed to `Read` `bufio.Reader.Read(p)` may read fewer than `len(p)` bytes from the underlying `io.Reader` into `p`. When it does, archive members appear artificially truncated; when this happens to the string table, it leads to red herring errors (e.g. missing entries, missing trailing newlines). After capping `len(p)` to the remaining number of bytes to be read from the current member's data section, ensure that exactly `len(p)` bytes are read from the underlying `io.Reader` when reading the string table. --- reader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reader.go b/reader.go index ee213e2..a0e7b76 100644 --- a/reader.go +++ b/reader.go @@ -283,7 +283,7 @@ func (rd *Reader) Read(b []byte) (n int, err error) { if int64(len(b)) > rd.nb { b = b[0:rd.nb] } - n, err = rd.r.Read(b) + n, err = io.ReadFull(rd.r, b) rd.nb -= int64(n) return