mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add test for invalid tarball read
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
This commit is contained in:
parent
094926206b
commit
aedcb76adc
2 changed files with 29 additions and 0 deletions
|
@ -137,3 +137,32 @@ func TestTypeXGlobalHeaderDoesNotFail(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some tar have both GNU specific (huge uid) and Ustar specific (long name) things.
|
||||||
|
// Not supposed to happen (should use PAX instead of Ustar for long name) but it does and it should still work.
|
||||||
|
func TestUntarUstarGnuConflict(t *testing.T) {
|
||||||
|
f, err := os.Open("testdata/broken.tar")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
found := false
|
||||||
|
tr := tar.NewReader(f)
|
||||||
|
// Iterate through the files in the archive.
|
||||||
|
for {
|
||||||
|
hdr, err := tr.Next()
|
||||||
|
if err == io.EOF {
|
||||||
|
// end of tar archive
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if hdr.Name == "root/.cpanm/work/1395823785.24209/Plack-1.0030/blib/man3/Plack::Middleware::LighttpdScriptNameFix.3pm" {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Fatal("%s not found in the archive", "root/.cpanm/work/1395823785.24209/Plack-1.0030/blib/man3/Plack::Middleware::LighttpdScriptNameFix.3pm")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
BIN
archive/testdata/broken.tar
vendored
Normal file
BIN
archive/testdata/broken.tar
vendored
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue