]> Cypherpunks repositories - gostls13.git/commitdiff
compress: update documentation regarding footer verification
authorJoe Tsai <joetsai@digital-static.net>
Mon, 28 Mar 2016 09:29:18 +0000 (02:29 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Mon, 9 May 2016 19:19:24 +0000 (19:19 +0000)
Address two documentation issues:
1) Document that the GZIP and ZLIB footer is only verified when the
reader has been fully consumed.
2) The zlib reader is guaranteed to not read past the EOF if the
input io.Reader is also a io.ByteReader. This functionality was
documented in the flate and gzip packages but not on zlib.

Fixes #14867

Change-Id: I43d46b93e38f98a04901dc7d4f18ed2f9e09f6fb
Reviewed-on: https://go-review.googlesource.com/21218
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/compress/gzip/gunzip.go
src/compress/zlib/reader.go

index 926bae88c70bdae2803b759bb6f4e9c1abb315e6..7e640692f3f265376f5383f6b41b88563f764308 100644 (file)
@@ -282,4 +282,6 @@ func (z *Reader) Read(p []byte) (n int, err error) {
 }
 
 // Close closes the Reader. It does not close the underlying io.Reader.
+// In order for the GZIP checksum to be verified, the reader must be
+// fully consumed until the io.EOF.
 func (z *Reader) Close() error { return z.decompressor.Close() }
index 30535fd980e55bb180d57c05c701c36eec9b0415..2efa1930354585aaa02367b37c1e9025457abae6 100644 (file)
@@ -62,7 +62,8 @@ type Resetter interface {
 
 // NewReader creates a new ReadCloser.
 // Reads from the returned ReadCloser read and decompress data from r.
-// The implementation buffers input and may read more data than necessary from r.
+// If r does not implement io.ByteReader, the decompressor may read more
+// data than necessary from r.
 // It is the caller's responsibility to call Close on the ReadCloser when done.
 //
 // The ReadCloser returned by NewReader also implements Resetter.
@@ -115,6 +116,8 @@ func (z *reader) Read(p []byte) (int, error) {
 }
 
 // Calling Close does not close the wrapped io.Reader originally passed to NewReader.
+// In order for the ZLIB checksum to be verified, the reader must be
+// fully consumed until the io.EOF.
 func (z *reader) Close() error {
        if z.err != nil && z.err != io.EOF {
                return z.err