From 3d475bc56886c8183b3189b762451095985b6c84 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 24 Jun 2024 11:39:39 +0200 Subject: prog: reduce amount of hint replacements Several optimizations to reduce amount of hint replacements: 1. Don't mutate int's that are <= 8 bits. 2. Don't mutate data that is <= 3 bytes. 3. Restrict mutation of len only value >10 and < 1<<20. Values <= 10 we can produce during normal mutation. Values > 1<<20 are presumably not length of something and we have logic to produce various large bogus lengths. 4. Include all small ints <= 16 into specialInts and remove 31, 32, 63 (don't remember where they come from). 5. Don't produce other known flags (and combinations) for flags. And a larger part computes groups of related arguments so that we don't try to produce known ioctl's from other known ioctl's, and similarly for socket/socketpair/setsockopt/etc. See comments in Target.initRelatedFields for details. Update #477 --- pkg/hash/hash.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/hash/hash.go b/pkg/hash/hash.go index 246fc4b2f..5b325fa34 100644 --- a/pkg/hash/hash.go +++ b/pkg/hash/hash.go @@ -13,17 +13,17 @@ import ( type Sig [sha1.Size]byte -func Hash(pieces ...[]byte) Sig { +func Hash(pieces ...any) Sig { h := sha1.New() for _, data := range pieces { - h.Write(data) + binary.Write(h, binary.LittleEndian, data) } var sig Sig copy(sig[:], h.Sum(nil)) return sig } -func String(pieces ...[]byte) string { +func String(pieces ...any) string { sig := Hash(pieces...) return sig.String() } -- cgit mrf-deployment