Skip to content

Commit

Permalink
limiting might reader, might result in broken json
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf committed May 28, 2024
1 parent 646ef4a commit c89d584
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/contexts/ocm/accessmethods/npm/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,15 @@ func (a *AccessSpec) GetPackageVersion(ctx accspeccpi.Context) (*npm.Version, er
if err != nil {
return nil, err
}
buf := &bytes.Buffer{}
_, err = io.Copy(buf, io.LimitReader(r, 200000))
buf, err := io.ReadAll(r)
if err != nil {
return nil, errors.Wrapf(err, "cannot get version metadata for %s", a.PackageVersionUrl())
}
var version npm.Version
err = json.Unmarshal(buf.Bytes(), &version)
err = json.Unmarshal(buf, &version)
if err != nil || version.Dist.Tarball == "" {
var project npm.Project
err = json.Unmarshal(buf.Bytes(), &project)
err = json.Unmarshal(buf, &project)
if err != nil {
return nil, errors.Wrapf(err, "cannot unmarshal version metadata for %s", a.PackageVersionUrl())
}
Expand Down

0 comments on commit c89d584

Please sign in to comment.