]> Cypherpunks repositories - gostls13.git/commit
archive/tar: avoid empty IO operations
authorJoe Tsai <joetsai@digital-static.net>
Mon, 25 Sep 2017 22:03:49 +0000 (15:03 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Mon, 25 Sep 2017 23:06:04 +0000 (23:06 +0000)
commit7246585f8c4211df2b678639ba58a72f70573c3c
tree33be76bef11172f4973f1d5783eceaae5d565b03
parent57f7bc3a057a4e104349e72f2834d5e47e8518bd
archive/tar: avoid empty IO operations

The interfaces for io.Reader and io.Writer permit calling Read/Write
with an empty buffer. However, this condition is often not well tested
and can lead to bugs in various implementations of io.Reader and io.Writer.
For example, see #22028 for buggy io.Reader in the bzip2 package.

We reduce the likelihood of hitting these bugs by adjusting
regFileReader.Read and regFileWriter.Write to avoid performing
Read and Write calls when the buffer is known to be empty.

Fixes #22029

Change-Id: Ie4a26be53cf87bc4d2abd951fa005db5871cc75c
Reviewed-on: https://go-review.googlesource.com/66111
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/archive/tar/reader.go
src/archive/tar/reader_test.go
src/archive/tar/writer.go
src/archive/tar/writer_test.go