@@ -32,6 +32,7 @@ import (
3232
3333 "github.com/containerd/containerd/content"
3434 "github.com/containerd/containerd/content/local"
35+ "github.com/containerd/containerd/images/archive"
3536)
3637
3738// checkBlobPath performs some basic validation
@@ -87,8 +88,7 @@ func populateBlobStore(ctx context.Context, cs content.Store, f *fuzz.ConsumeFuz
8788 }
8889
8990 for dgst , p := range blobs {
90- d , err := checkWrite (ctx , cs , dgst , p )
91- _ = d
91+ _ , err := checkWrite (ctx , cs , dgst , p )
9292 if err != nil {
9393 return blobs , err
9494 }
@@ -112,7 +112,6 @@ func FuzzCSWalk(data []byte) int {
112112
113113 f := fuzz .NewConsumer (data )
114114 blobs , err := populateBlobStore (ctx , cs , f )
115- _ = blobs
116115 if err != nil {
117116 return 0
118117 }
@@ -136,3 +135,34 @@ func FuzzCSWalk(data []byte) int {
136135 }
137136 return 1
138137}
138+
139+ func FuzzArchiveExport (data []byte ) int {
140+ f := fuzz .NewConsumer (data )
141+ manifest := ocispec.Descriptor {}
142+ err := f .GenerateStruct (& manifest )
143+ if err != nil {
144+ return 0
145+ }
146+ ctx := context .Background ()
147+ tmpdir , err := ioutil .TempDir ("" , "fuzzing-" )
148+ if err != nil {
149+ return 0
150+ }
151+ defer os .RemoveAll (tmpdir )
152+ cs , err := local .NewStore (tmpdir )
153+ if err != nil {
154+ return 0
155+ }
156+ _ , err = populateBlobStore (ctx , cs , f )
157+ if err != nil {
158+ return 0
159+ }
160+ w , err := os .Create ("fuzz-output-file" )
161+ if err != nil {
162+ return 0
163+ }
164+ defer w .Close ()
165+ defer os .Remove ("fuzz-output-file" )
166+ _ = archive .Export (ctx , cs , w , archive .WithManifest (manifest , "name" ))
167+ return 1
168+ }
0 commit comments