summaryrefslogtreecommitdiff
path: root/src/compress/gzip/gzip_test.go
Commit message (Collapse)AuthorAgeFilesLines
* all: update references to symbols moved from io/ioutil to ioRuss Cox2020-10-201-5/+4
| | | | | | | | | | | | | | | | | | | The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* compress/gzip: add missing error check in testLeon Klingele2019-05-241-0/+3
| | | | | | | | | Change-Id: Ib7be503a46f3609ea29464569e57e1f620e97a53 GitHub-Last-Rev: a43cffe45f3b9d208028f7682088cbe537d6deca GitHub-Pull-Request: golang/go#30007 Reviewed-on: https://go-review.googlesource.com/c/go/+/160431 Run-TryBot: Leon Klingele <git@leonklingele.de> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* compress/gzip: do not count header bytes written in WriteTravis Bischel2018-04-021-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, if an underlying writer errored within 10 bytes (plus any gzip header metadata), a gzip.Write would erroneously report up to 10 bytes written that were not actually written of the input slice. This is especially problematic when the input slice is less than 10 bytes. The error came from counting the 10 header byte write. If writing the header is completely successful, the 10 bytes written is overridden by the flate write with the input slice. This removes counting the 10 required header bytes, and also changes the return to use zero until the slice is used. The old Write could return one byte written when it actually was not. This is difficult to verify because the smallest input slice is one byte; a test checking that the input slice was the byte written would be quite involved. Thankfully, gzip's minimum header write is 10 bytes. If we test that two bytes are not falsely written, we indirectly cover the one byte case. Fixes #24625 Change-Id: I1c1f8cd791e0c4cffc22aa8acd95186582c832ba Reviewed-on: https://go-review.googlesource.com/103861 Reviewed-by: Joe Tsai <joetsai@google.com> Run-TryBot: Joe Tsai <joetsai@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* compress/gzip: only encode MTIME if it is validJoe Tsai2016-10-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The GZIP format records the ModTime as an uint32 counting seconds since the Unix epoch. The zero value is explicitly defined in section 2.3.1 as meaning no timestamp is available. Currently, the Writer always encodes the ModTime even if it is the zero time.Time value, which causes the Writer to try and encode the value -62135596800 into the uint32 MTIME field. This causes an overflow and results in our GZIP files having MTIME fields indicating a date in 2042-07-13. We alter the Writer to only encode ModTime if the value does not underflow the MTIME field (i.e., it is newer than the Unix epoch). We do not attempt to fix what happens when the timestamp overflows in the year 2106. We alter the Reader to only decode ModTime if the value is non-zero. There is no risk of overflowing time.Time when decoding. Fixes #17663 Change-Id: Ie1b65770c6342cd7b14aeebe10e5a49e6c9eb730 Reviewed-on: https://go-review.googlesource.com/32325 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+231
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.