Commit cd0ba4c1 authored by Joe Tsai's avatar Joe Tsai Committed by Joe Tsai

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent d1a19235
This diff is collapsed.
......@@ -229,6 +229,14 @@ var untarTests = []*untarTest{
},
},
},
{
file: "testdata/pax-bad-hdr-file.tar",
err: ErrHeader,
},
{
file: "testdata/pax-bad-mtime-file.tar",
err: ErrHeader,
},
{
file: "testdata/nil-uid.tar", // golang.org/issue/5290
headers: []*Header{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment