From 9b87721c1f22ae5f5372abe9f7ced9bd3d075c9d Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Tue, 24 Sep 2019 13:59:14 -0600 Subject: [PATCH] fix(provenance): Ports error check for `Digest` to v3 This is a port of #5672 Signed-off-by: Taylor Thomas --- pkg/provenance/sign.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/provenance/sign.go b/pkg/provenance/sign.go index 469205527..6e828ff5d 100644 --- a/pkg/provenance/sign.go +++ b/pkg/provenance/sign.go @@ -402,6 +402,8 @@ func DigestFile(filename string) (string, error) { // Helm uses SHA256 as its default hash for all non-cryptographic applications. func Digest(in io.Reader) (string, error) { hash := crypto.SHA256.New() - io.Copy(hash, in) + if _, err := io.Copy(hash, in); err != nil { + return "", nil + } return hex.EncodeToString(hash.Sum(nil)), nil }