Skip to content

Commit 9e4acc0

Browse files
committed
importer: stream oci-layout and manifest.json
Signed-off-by: Samuel Karp <[email protected]>
1 parent a43d719 commit 9e4acc0

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
@@ -233,12 +233,14 @@ func ImportIndex(ctx context.Context, store content.Store, reader io.Reader, opt
233233
return writeManifest(ctx, store, idx, ocispec.MediaTypeImageIndex)
234234
}
235235

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

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

0 commit comments

Comments
 (0)