2022-08-19 16:34:07 +00:00
|
|
|
//go:build gofuzz
|
2019-06-09 07:24:20 +00:00
|
|
|
// +build gofuzz
|
|
|
|
|
|
|
|
package multistream
|
|
|
|
|
|
|
|
import "bytes"
|
|
|
|
|
|
|
|
type rwc struct {
|
|
|
|
*bytes.Reader
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*rwc) Write(b []byte) (int, error) {
|
|
|
|
return len(b), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*rwc) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func Fuzz(b []byte) int {
|
|
|
|
readStream := bytes.NewReader(b)
|
|
|
|
input := &rwc{readStream}
|
|
|
|
|
|
|
|
mux := NewMultistreamMuxer()
|
|
|
|
mux.AddHandler("/a", nil)
|
|
|
|
mux.AddHandler("/b", nil)
|
|
|
|
_ = mux.Handle(input)
|
|
|
|
return 1
|
|
|
|
}
|