importer: stream oci-layout and manifest.json

Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
Samuel Karp 2023-01-12 18:06:41 -08:00
parent a43d719ce2
commit 9e4acc0280
No known key found for this signature in database
GPG Key ID: 997C5A3CD3167CB5

View File

@ -233,12 +233,14 @@ func ImportIndex(ctx context.Context, store content.Store, reader io.Reader, opt
return writeManifest(ctx, store, idx, ocispec.MediaTypeImageIndex)
}
const (
kib = 1024
mib = 1024 * kib
jsonLimit = 20 * mib
)
func onUntarJSON(r io.Reader, j interface{}) error {
b, err := io.ReadAll(r)
if err != nil {
return err
}
return json.Unmarshal(b, j)
return json.NewDecoder(io.LimitReader(r, jsonLimit)).Decode(j)
}
func onUntarBlob(ctx context.Context, r io.Reader, store content.Ingester, size int64, ref string) (digest.Digest, error) {