Skip to content

Commit

Permalink
Merge pull request #14980 from n1hility/fix-leak
Browse files Browse the repository at this point in the history
Fix potential body leak on mid-stream read error when fetching artifact version
  • Loading branch information
openshift-merge-robot authored Jul 21, 2022
2 parents 0de7e46 + a652659 commit 712267e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/machine/fedora.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func getFedoraDownload(releaseURL string) (*url.URL, string, int64, error) {
return nil, "", -1, fmt.Errorf("get request failed: %s: %w", verURL.String(), err)
}

defer resp.Body.Close()
bytes, err := io.ReadAll(&io.LimitedReader{R: resp.Body, N: 1024})
if err != nil {
return nil, "", -1, fmt.Errorf("failed reading: %s: %w", verURL.String(), err)
}
_ = resp.Body.Close()

return downloadURL, strings.TrimSpace(string(bytes)), contentLen, nil
}

0 comments on commit 712267e

Please sign in to comment.