Skip to content

Commit

Permalink
importer: stream oci-layout and manifest.json
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 9e4acc0)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
  • Loading branch information
samuelkarp committed Feb 8, 2023
1 parent 4335c65 commit 84936fd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions images/archive/importer.go
Expand Up @@ -232,12 +232,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) {
Expand Down

0 comments on commit 84936fd

Please sign in to comment.