1
0
Fork 0
tar-split/archive/tar
Joe Tsai bffda594f7 archive/tar: detect truncated files
Motivation:
* Reader.skipUnread never reports io.ErrUnexpectedEOF. This is strange
given that io.ErrUnexpectedEOF is given through Reader.Read if the
user manually reads the file.
* Reader.skipUnread fails to detect truncated files since io.Seeker
is lazy about reporting errors. Thus, the behavior of Reader differs
whether the input io.Reader also satisfies io.Seeker or not.

To solve this, we seek to one before the end of the data section and
always rely on at least one call to io.CopyN. If the tr.r satisfies
io.Seeker, this is guarunteed to never read more than blockSize.

Fixes #12557

Change-Id: I0ddddfc6bed0d74465cb7e7a02b26f1de7a7a279
Reviewed-on: https://go-review.googlesource.com/15175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-02 14:09:30 -05:00
..
testdata archive/tar: fix round-trip attributes 2015-08-21 00:15:22 -04:00
common.go archive/tar: move round-trip reading into common os file 2015-08-21 00:15:22 -04:00
example_test.go archive/tar: adding from go as of a9dddb53f 2015-02-11 14:08:03 +01:00
reader.go archive/tar: fix numeric overflow issues in readGNUSparseMap0x1 2016-02-02 14:09:04 -05:00
reader_test.go archive/tar: fix numeric overflow issues in readGNUSparseMap0x1 2016-02-02 14:09:04 -05:00
stat_atim.go archive/tar: adding from go as of a9dddb53f 2015-02-11 14:08:03 +01:00
stat_atimespec.go archive/tar: adding from go as of a9dddb53f 2015-02-11 14:08:03 +01:00
stat_unix.go archive/tar: don't treat multiple file system links as a tar hardlink 2015-08-21 00:15:22 -04:00
tar_test.go archive/tar: move round-trip reading into common os file 2015-08-21 00:15:22 -04:00
writer.go archive/tar: detect truncated files 2016-02-02 14:09:30 -05:00
writer_test.go archive/tar: detect truncated files 2016-02-02 14:09:30 -05:00