Skip to content

Commit 84936fd

Browse files
committed
importer: stream oci-layout and manifest.json
Signed-off-by: Samuel Karp <[email protected]> (cherry picked from commit 9e4acc0) Signed-off-by: Samuel Karp <[email protected]>
1 parent 4335c65 commit 84936fd

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

images/archive/importer.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,14 @@ func ImportIndex(ctx context.Context, store content.Store, reader io.Reader, opt
232232
return writeManifest(ctx, store, idx, ocispec.MediaTypeImageIndex)
233233
}
234234

235+
const (
236+
kib = 1024
237+
mib = 1024 * kib
238+
jsonLimit = 20 * mib
239+
)
240+
235241
func onUntarJSON(r io.Reader, j interface{}) error {
236-
b, err := io.ReadAll(r)
237-
if err != nil {
238-
return err
239-
}
240-
return json.Unmarshal(b, j)
242+
return json.NewDecoder(io.LimitReader(r, jsonLimit)).Decode(j)
241243
}
242244

243245
func onUntarBlob(ctx context.Context, r io.Reader, store content.Ingester, size int64, ref string) (digest.Digest, error) {

0 commit comments

Comments
 (0)