mirror of
https://github.com/vbatts/tar-split.git
synced 2024-12-18 11:36:30 +00:00
archive/tar: add missing error checks
Check for errors when reading the headers following the pax headers. Fixes #11169. Change-Id: Ifec4a949ec8df8b49fa7cb7a67eb826fe2282ad8 Reviewed-on: https://go-review.googlesource.com/11031 Reviewed-by: Russ Cox <rsc@golang.org> Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
69de764807
commit
2e5698249c
3 changed files with 21 additions and 0 deletions
|
@ -138,7 +138,13 @@ func (tr *Reader) Next() (*Header, error) {
|
|||
// We actually read the whole file,
|
||||
// but this skips alignment padding
|
||||
tr.skipUnread()
|
||||
if tr.err != nil {
|
||||
return nil, tr.err
|
||||
}
|
||||
hdr = tr.readHeader()
|
||||
if hdr == nil {
|
||||
return nil, tr.err
|
||||
}
|
||||
mergePAX(hdr, headers)
|
||||
|
||||
// Check for a PAX format sparse file
|
||||
|
|
|
@ -781,3 +781,18 @@ func TestIssue10968(t *testing.T) {
|
|||
t.Fatalf("expected %q, got %q", io.ErrUnexpectedEOF, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Do not panic if there are errors in header blocks after the pax header.
|
||||
// Issue 11169
|
||||
func TestIssue11169(t *testing.T) {
|
||||
f, err := os.Open("testdata/issue11169.tar")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
r := NewReader(f)
|
||||
_, err = r.Next()
|
||||
if err == nil {
|
||||
t.Fatal("Unexpected success")
|
||||
}
|
||||
}
|
||||
|
|
BIN
archive/tar/testdata/issue11169.tar
vendored
Normal file
BIN
archive/tar/testdata/issue11169.tar
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue