From 0a6f9bc1eb541867b6134823c892545624090f49 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 9 Nov 2021 15:28:08 -0800 Subject: [PATCH] allocate new highwayhash for each string hash (#13623) fixes #13622 --- internal/logger/logger.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 74f4cbb2f..226048ca7 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" "go/build" - "hash" "net/http" "path/filepath" "reflect" @@ -39,8 +38,6 @@ import ( var ( // HighwayHash key for logging in anonymous mode magicHighwayHash256Key = []byte("\x4b\xe7\x34\xfa\x8e\x23\x8a\xcd\x26\x3e\x83\xe6\xbb\x96\x85\x52\x04\x0f\x93\x5d\xa3\x9f\x44\x14\x97\xe0\x9d\x13\x22\xde\x36\xa0") - // HighwayHash hasher for logging in anonymous mode - loggerHighwayHasher hash.Hash ) // Disable disables all logging, false by default. (used for "go test") @@ -207,8 +204,6 @@ func Init(goPath string, goRoot string) { // paths like "{GOROOT}/src/github.com/minio/minio" // and "{GOPATH}/src/github.com/minio/minio" trimStrings = append(trimStrings, filepath.Join("github.com", "minio", "minio")+string(filepath.Separator)) - - loggerHighwayHasher, _ = highwayhash.New(magicHighwayHash256Key) // New will never return error since key is 256 bit } func trimTrace(f string) string { @@ -263,10 +258,9 @@ func getTrace(traceLevel int) []string { // Return the highway hash of the passed string func hashString(input string) string { - defer loggerHighwayHasher.Reset() - loggerHighwayHasher.Write([]byte(input)) - checksum := loggerHighwayHasher.Sum(nil) - return hex.EncodeToString(checksum) + hh, _ := highwayhash.New(magicHighwayHash256Key) + hh.Write([]byte(input)) + return hex.EncodeToString(hh.Sum(nil)) } // Kind specifies the kind of error log