diff --git a/pkg/update/update.go b/pkg/update/update.go index d380e9c9b0..5f5c6bcbce 100644 --- a/pkg/update/update.go +++ b/pkg/update/update.go @@ -51,7 +51,7 @@ func DownloadWithSHA512Hash(url string, out io.Writer, size int64, expectedHash // Validate the hash matches gotHash := hash.Sum(nil) - if bytes.Compare(gotHash, expectedHash) != 0 { + if !bytes.Equal(gotHash, expectedHash) { return errors.Errorf( "hash %s does not match expected %s", base64.StdEncoding.EncodeToString(gotHash), diff --git a/pkg/update/update_test.go b/pkg/update/update_test.go index 94a5204abf..75ed1cca3c 100644 --- a/pkg/update/update_test.go +++ b/pkg/update/update_test.go @@ -41,7 +41,7 @@ func TestDownloadWithSHA512Hash(t *testing.T) { expectedHash, expectedLen := sha512Hash(expectedData), int64(len(expectedData)) ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, string(expectedData)) + fmt.Fprint(w, string(expectedData)) })) defer ts.Close() @@ -59,7 +59,7 @@ func TestDownloadWithSHA512HashTooSmall(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Don't write all of data - fmt.Fprintf(w, string(expectedData[:2])) + fmt.Fprint(w, string(expectedData[:2])) })) defer ts.Close() @@ -93,7 +93,7 @@ func TestDownloadWithSHA512HashMismatch(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Write non-matching data - fmt.Fprintf(w, string("def")) + fmt.Fprint(w, string("def")) })) defer ts.Close()