]> Cypherpunks repositories - gostls13.git/commit
archive/tar: make Reader error handling consistent
authorJoe Tsai <joetsai@digital-static.net>
Mon, 29 Aug 2016 23:10:32 +0000 (16:10 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Wed, 31 Aug 2016 23:22:53 +0000 (23:22 +0000)
commitcd0ba4c169b591cc22f51cb61463eb45af7b930d
tree13c4add5a760cf88aaa100bd46c4b7b6e8822127
parentd1a19235212d62843c17dc4f7c61d46bb1bf56ff
archive/tar: make Reader error handling consistent

The tar.Reader guarantees stickiness of errors. Ensuring this property means
that the methods of Reader need to be consistent about whose responsibility it
is to actually ensure that errors are sticky.

In this CL, we make it only the responsibility of the exported methods
(Next and Read) to store tr.err. All other methods just return the error as is.

As part of this change, we also check the error value of mergePAX (and test
that it properly detects invalid PAX files). Since the value of mergePAX was
never used before, we change it such that it always returns ErrHeader instead
of strconv.SyntaxError. This keeps it consistent with other usages of strconv
in the same tar package.

Change-Id: Ia1c31da71f1de4c175da89a385dec665d3edd167
Reviewed-on: https://go-review.googlesource.com/28215
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/archive/tar/reader.go
src/archive/tar/reader_test.go
src/archive/tar/testdata/pax-bad-hdr-file.tar [new file with mode: 0644]
src/archive/tar/testdata/pax-bad-mtime-file.tar [new file with mode: 0644]