github.com/fraugster/parquet-go@v0.12.0/hybrid_fuzz.go (about) 1 //go:build gofuzz 2 // +build gofuzz 3 4 package goparquet 5 6 import ( 7 "bytes" 8 "fmt" 9 "math/bits" 10 ) 11 12 func FuzzHybrid(data []byte) int { 13 14 l := len(data) 15 16 bigLoop: 17 for w := 1; w <= 32; w++ { 18 d := newHybridDecoder(w) 19 if err := d.init(bytes.NewReader(data)); err != nil { 20 continue bigLoop 21 } 22 23 maxCount := l / w 24 for i := 0; i < maxCount; i++ { 25 v, err := d.next() 26 if err != nil { 27 continue bigLoop 28 } 29 if bits.LeadingZeros32(uint32(v)) < 32-w { 30 panic(fmt.Sprintf("decoded value %d is too large for width %d", v, w)) 31 } 32 } 33 return 1 34 } 35 return 0 36 }