Anton Kaliaev
7 years ago
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with
31 additions and
0 deletions
-
consensus/wal_fuzz.go
|
|
@ -0,0 +1,31 @@ |
|
|
|
// +build gofuzz
|
|
|
|
|
|
|
|
package consensus |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"io" |
|
|
|
) |
|
|
|
|
|
|
|
func Fuzz(data []byte) int { |
|
|
|
dec := NewWALDecoder(bytes.NewReader(data)) |
|
|
|
for { |
|
|
|
msg, err := dec.Decode() |
|
|
|
if err == io.EOF { |
|
|
|
break |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if msg != nil { |
|
|
|
panic("msg != nil on error") |
|
|
|
} |
|
|
|
return 0 |
|
|
|
} |
|
|
|
var w bytes.Buffer |
|
|
|
enc := NewWALEncoder(&w) |
|
|
|
err = enc.Encode(msg) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
} |
|
|
|
return 1 |
|
|
|
} |