]> Cypherpunks repositories - gostls13.git/commitdiff
archive/tar: document how Reader.Read handles header-only files
authorJoe Tsai <joetsai@digital-static.net>
Thu, 17 Dec 2015 07:10:14 +0000 (23:10 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 17 Dec 2015 15:48:10 +0000 (15:48 +0000)
Commit dd5e14a7511465d20c6e95bf54c9b8f999abbbf6 ensured that no data
could be read for header-only files regardless of what the Header.Size
said. We should document this fact in Reader.Read.

Updates #13647

Change-Id: I4df9a2892bc66b49e0279693d08454bf696cfa31
Reviewed-on: https://go-review.googlesource.com/17913
Reviewed-by: Russ Cox <rsc@golang.org>
src/archive/tar/reader.go

index 4aa7edbce397cc4a7ea36f6e7d32e42b73b6987e..c8cb69a17841b88f1f232ca05e84f53e00287e1f 100644 (file)
@@ -857,6 +857,10 @@ func (tr *Reader) numBytes() int64 {
 // Read reads from the current entry in the tar archive.
 // It returns 0, io.EOF when it reaches the end of that entry,
 // until Next is called to advance to the next entry.
+//
+// Calling Read on special types like TypeLink, TypeSymLink, TypeChar,
+// TypeBlock, TypeDir, and TypeFifo returns 0, io.EOF regardless of what
+// the Header.Size claims.
 func (tr *Reader) Read(b []byte) (n int, err error) {
        if tr.err != nil {
                return 0, tr.err