Skip to content

Commit

Permalink
Merge pull request from GHSA-259w-8hf6-59c2
Browse files Browse the repository at this point in the history
[release/1.5] importer: stream oci-layout and manifest.json
  • Loading branch information
dmcgowan authored Feb 15, 2023
2 parents b4538c2 + 19a347e commit 959e1cf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions images/archive/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"path"

"github.com/containerd/containerd/archive/compression"
Expand Down Expand Up @@ -222,12 +221,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 := ioutil.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 959e1cf

Please sign in to comment.