Skip to content

Commit 19a347e

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 6c00831 commit 19a347e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

images/archive/importer.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"encoding/json"
2525
"fmt"
2626
"io"
27-
"io/ioutil"
2827
"path"
2928

3029
"github.com/containerd/containerd/archive/compression"
@@ -222,12 +221,14 @@ func ImportIndex(ctx context.Context, store content.Store, reader io.Reader, opt
222221
return writeManifest(ctx, store, idx, ocispec.MediaTypeImageIndex)
223222
}
224223

224+
const (
225+
kib = 1024
226+
mib = 1024 * kib
227+
jsonLimit = 20 * mib
228+
)
229+
225230
func onUntarJSON(r io.Reader, j interface{}) error {
226-
b, err := ioutil.ReadAll(r)
227-
if err != nil {
228-
return err
229-
}
230-
return json.Unmarshal(b, j)
231+
return json.NewDecoder(io.LimitReader(r, jsonLimit)).Decode(j)
231232
}
232233

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

0 commit comments

Comments
 (0)