github.com/jwhonce/docker@v0.6.7-0.20190327063223-da823cf3a5a3/integration/image/import_test.go (about) 1 package image // import "github.com/docker/docker/integration/image" 2 3 import ( 4 "archive/tar" 5 "bytes" 6 "context" 7 "io" 8 "runtime" 9 "testing" 10 11 "github.com/docker/docker/api/types" 12 "github.com/docker/docker/internal/test/daemon" 13 "github.com/docker/docker/internal/testutil" 14 "gotest.tools/assert" 15 "gotest.tools/skip" 16 ) 17 18 // Ensure we don't regress on CVE-2017-14992. 19 func TestImportExtremelyLargeImageWorks(t *testing.T) { 20 skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") 21 skip.If(t, runtime.GOARCH == "arm64", "effective test will be time out") 22 skip.If(t, testEnv.OSType == "windows", "TODO enable on windows") 23 t.Parallel() 24 25 // Spin up a new daemon, so that we can run this test in parallel (it's a slow test) 26 d := daemon.New(t) 27 d.Start(t) 28 defer d.Stop(t) 29 30 client := d.NewClientT(t) 31 32 // Construct an empty tar archive with about 8GB of junk padding at the 33 // end. This should not cause any crashes (the padding should be mostly 34 // ignored). 35 var tarBuffer bytes.Buffer 36 37 tw := tar.NewWriter(&tarBuffer) 38 err := tw.Close() 39 assert.NilError(t, err) 40 imageRdr := io.MultiReader(&tarBuffer, io.LimitReader(testutil.DevZero, 8*1024*1024*1024)) 41 42 _, err = client.ImageImport(context.Background(), 43 types.ImageImportSource{Source: imageRdr, SourceName: "-"}, 44 "test1234:v42", 45 types.ImageImportOptions{}) 46 assert.NilError(t, err) 47 }