diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 29585fe..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*-fuzz.zip diff --git a/multistream.go b/multistream.go index daca87c..17e1ef7 100644 --- a/multistream.go +++ b/multistream.go @@ -7,10 +7,9 @@ import ( "bufio" "errors" "fmt" + "io" "os" "runtime/debug" - - "io" "sync" "github.com/multiformats/go-varint" diff --git a/multistream_fuzz.go b/multistream_fuzz.go deleted file mode 100644 index 49eb797..0000000 --- a/multistream_fuzz.go +++ /dev/null @@ -1,28 +0,0 @@ -//go: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 -} diff --git a/multistream_test.go b/multistream_test.go index 0398a13..43b5f94 100644 --- a/multistream_test.go +++ b/multistream_test.go @@ -7,6 +7,7 @@ import ( "io" "net" "sort" + "strings" "testing" "time" ) @@ -969,3 +970,30 @@ func TestSimopenClientClientFail(t *testing.T) { case <-done: } } + +type rwc struct { + *strings.Reader +} + +func (*rwc) Write(b []byte) (int, error) { + return len(b), nil +} + +func (*rwc) Close() error { + return nil +} + +func FuzzMultistream(f *testing.F) { + f.Add("/libp2p/simultaneous-connect") + f.Add(ProtocolID) + + f.Fuzz(func(t *testing.T, b string) { + readStream := strings.NewReader(b) + input := &rwc{readStream} + + mux := NewMultistreamMuxer[string]() + mux.AddHandler("/a", nil) + mux.AddHandler("/b", nil) + _ = mux.Handle(input) + }) +} diff --git a/workdir/corpus/006d5533770e47f781f838970cf1678c3109f9e3-2 b/workdir/corpus/006d5533770e47f781f838970cf1678c3109f9e3-2 deleted file mode 100644 index 498efe3..0000000 --- a/workdir/corpus/006d5533770e47f781f838970cf1678c3109f9e3-2 +++ /dev/null @@ -1 +0,0 @@ -���� \ No newline at end of file diff --git a/workdir/corpus/0b2e00d89397c0966a65c9c63871862f5d939ed2-5 b/workdir/corpus/0b2e00d89397c0966a65c9c63871862f5d939ed2-5 deleted file mode 100644 index 5e31674..0000000 Binary files a/workdir/corpus/0b2e00d89397c0966a65c9c63871862f5d939ed2-5 and /dev/null differ diff --git a/workdir/corpus/16c7381993e3c7382f77bed399f36ad2d64951f5-4 b/workdir/corpus/16c7381993e3c7382f77bed399f36ad2d64951f5-4 deleted file mode 100644 index b957a72..0000000 --- a/workdir/corpus/16c7381993e3c7382f77bed399f36ad2d64951f5-4 +++ /dev/null @@ -1 +0,0 @@ -���ソ���ス��ソ��スソ��� \ No newline at end of file diff --git a/workdir/corpus/23833462f55515a900e016db2eb943fb474c19f6-2 b/workdir/corpus/23833462f55515a900e016db2eb943fb474c19f6-2 deleted file mode 100644 index 16e0e90..0000000 --- a/workdir/corpus/23833462f55515a900e016db2eb943fb474c19f6-2 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/workdir/corpus/29368200289b4418d893fcc1cc269889e0a6bfb0-2 b/workdir/corpus/29368200289b4418d893fcc1cc269889e0a6bfb0-2 deleted file mode 100644 index e835914..0000000 --- a/workdir/corpus/29368200289b4418d893fcc1cc269889e0a6bfb0-2 +++ /dev/null @@ -1 +0,0 @@ -��ソ�� \ No newline at end of file diff --git a/workdir/corpus/599f2fcab2882f9e2896e49c68a5955e10dc7122-3 b/workdir/corpus/599f2fcab2882f9e2896e49c68a5955e10dc7122-3 deleted file mode 100644 index c9169ca..0000000 --- a/workdir/corpus/599f2fcab2882f9e2896e49c68a5955e10dc7122-3 +++ /dev/null @@ -1 +0,0 @@ -���������W \ No newline at end of file diff --git a/workdir/corpus/7a423337dc2c0923e996c50255f0c4a7702581d3-1 b/workdir/corpus/7a423337dc2c0923e996c50255f0c4a7702581d3-1 deleted file mode 100644 index 2d31828..0000000 --- a/workdir/corpus/7a423337dc2c0923e996c50255f0c4a7702581d3-1 +++ /dev/null @@ -1 +0,0 @@ -� \ No newline at end of file diff --git a/workdir/corpus/8750ec9ddfe293cd1dc39b4245c21c270f8f52b7-1 b/workdir/corpus/8750ec9ddfe293cd1dc39b4245c21c270f8f52b7-1 deleted file mode 100644 index 6b84f9d..0000000 --- a/workdir/corpus/8750ec9ddfe293cd1dc39b4245c21c270f8f52b7-1 +++ /dev/null @@ -1 +0,0 @@ -�� \ No newline at end of file diff --git a/workdir/corpus/8c377ec00ce8265e2fb3689c098e594f9b2a2c9a-2 b/workdir/corpus/8c377ec00ce8265e2fb3689c098e594f9b2a2c9a-2 deleted file mode 100644 index f4f438f..0000000 --- a/workdir/corpus/8c377ec00ce8265e2fb3689c098e594f9b2a2c9a-2 +++ /dev/null @@ -1 +0,0 @@ - diff --git a/workdir/corpus/957666b9194bb12689255437cfc23ddb79b9231a-3 b/workdir/corpus/957666b9194bb12689255437cfc23ddb79b9231a-3 deleted file mode 100644 index 6c4a409..0000000 --- a/workdir/corpus/957666b9194bb12689255437cfc23ddb79b9231a-3 +++ /dev/null @@ -1 +0,0 @@ -�ソ��スソ��� \ No newline at end of file diff --git a/workdir/corpus/9d8099103966bb2134e94f46e34c312ea366c6b2-1 b/workdir/corpus/9d8099103966bb2134e94f46e34c312ea366c6b2-1 deleted file mode 100644 index 2771b74..0000000 --- a/workdir/corpus/9d8099103966bb2134e94f46e34c312ea366c6b2-1 +++ /dev/null @@ -1 +0,0 @@ -G \ No newline at end of file diff --git a/workdir/corpus/a2f77d89c69a5551e3ae0f1e9825e45dfb95ee5d-1 b/workdir/corpus/a2f77d89c69a5551e3ae0f1e9825e45dfb95ee5d-1 deleted file mode 100644 index bc02e1d..0000000 Binary files a/workdir/corpus/a2f77d89c69a5551e3ae0f1e9825e45dfb95ee5d-1 and /dev/null differ diff --git a/workdir/corpus/b9ecf4a964523aa3508b6f1a001ef5466c067de6-6 b/workdir/corpus/b9ecf4a964523aa3508b6f1a001ef5466c067de6-6 deleted file mode 100644 index 551a4c1..0000000 --- a/workdir/corpus/b9ecf4a964523aa3508b6f1a001ef5466c067de6-6 +++ /dev/null @@ -1 +0,0 @@ -���ソ���ス��ソ��ソス�ソ���ス�ソ��スソ�ソ���ス� \ No newline at end of file diff --git a/workdir/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 b/workdir/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 deleted file mode 100644 index e69de29..0000000