summaryrefslogtreecommitdiff
path: root/pkg/machine
diff options
context:
space:
mode:
authorJason T. Greene <jason.greene@redhat.com>2022-07-19 14:06:47 -0500
committerMatthew Heon <matthew.heon@pm.me>2022-07-26 13:49:22 -0400
commit2350ef9dd4c0ffc7c92583b33f63da0bc9502bba (patch)
treef44e63dda986c1a192227aaaa8686507b9086352 /pkg/machine
parent7b28a1b7ccd885386044eee854d2308702588e51 (diff)
downloadpodman-2350ef9dd4c0ffc7c92583b33f63da0bc9502bba.tar.gz
podman-2350ef9dd4c0ffc7c92583b33f63da0bc9502bba.tar.bz2
podman-2350ef9dd4c0ffc7c92583b33f63da0bc9502bba.zip
Fix potential leak on mid-stream read error
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
Diffstat (limited to 'pkg/machine')
-rw-r--r--pkg/machine/fedora.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/machine/fedora.go b/pkg/machine/fedora.go
index 7ac4692e3..497265269 100644
--- a/pkg/machine/fedora.go
+++ b/pkg/machine/fedora.go
@@ -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
}