From: Russ Cox Date: Mon, 17 Oct 2022 13:29:05 +0000 (-0400) Subject: internal/fuzz: write shorter testdata corpus file names X-Git-Tag: go1.20rc1~610 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b65e259e56a326295250f037efbd31f64bcdfbfe;p=gostls13.git internal/fuzz: write shorter testdata corpus file names The only purpose of using the SHA256 in the file name is collision avoidance. Using just the first 64 bits (16 hex digits) will be more than enough, unless people start storing billions of test cases in their corpora. The shorter names are nicer for just about everything: command lines, repository listings, and so on. Change-Id: I67c760023bed85ba3ffd4f8058f86ef778322ba7 Reviewed-on: https://go-review.googlesource.com/c/go/+/443335 TryBot-Result: Gopher Robot Auto-Submit: Russ Cox Reviewed-by: Peter Weinberger Run-TryBot: Russ Cox --- diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go index f3f0d95469..d0eb92dd9f 100644 --- a/src/internal/fuzz/fuzz.go +++ b/src/internal/fuzz/fuzz.go @@ -1032,7 +1032,7 @@ func CheckCorpus(vals []any, types []reflect.Type) error { // writeToCorpus will not rewrite it. writeToCorpus sets entry.Path to the new // file that was just written or an error if it failed. func writeToCorpus(entry *CorpusEntry, dir string) (err error) { - sum := fmt.Sprintf("%x", sha256.Sum256(entry.Data)) + sum := fmt.Sprintf("%x", sha256.Sum256(entry.Data))[:16] entry.Path = filepath.Join(dir, sum) if err := os.MkdirAll(dir, 0777); err != nil { return err