From 18f52af5be3a9a0c73811706108f790d65ee9c67 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Mon, 29 Nov 2021 01:46:27 +0100 Subject: [pkg] update vendor --- vendor/github.com/pion/rtcp/fuzz.go | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 vendor/github.com/pion/rtcp/fuzz.go (limited to 'vendor/github.com/pion/rtcp/fuzz.go') diff --git a/vendor/github.com/pion/rtcp/fuzz.go b/vendor/github.com/pion/rtcp/fuzz.go new file mode 100644 index 0000000..2ea4fb1 --- /dev/null +++ b/vendor/github.com/pion/rtcp/fuzz.go @@ -0,0 +1,51 @@ +// +build gofuzz + +package rtcp + +import ( + "bytes" + "io" +) + +// Fuzz implements a randomized fuzz test of the rtcp +// parser using go-fuzz. +// +// To run the fuzzer, first download go-fuzz: +// `go get github.com/dvyukov/go-fuzz/...` +// +// Then build the testing package: +// `go-fuzz-build github.com/pion/webrtc` +// +// And run the fuzzer on the corpus: +// ``` +// mkdir workdir +// +// # optionally add a starter corpus of valid rtcp packets. +// # the corpus should be as compact and diverse as possible. +// cp -r ~/my-rtcp-packets workdir/corpus +// +// go-fuzz -bin=ase-fuzz.zip -workdir=workdir +// ```` +func Fuzz(data []byte) int { + r := NewReader(bytes.NewReader(data)) + for { + _, data, err := r.ReadPacket() + if err == io.EOF { + break + } + if err != nil { + return 0 + } + + packet, err := Unmarshal(data) + if err != nil { + return 0 + } + + if _, err := packet.Marshal(); err != nil { + return 0 + } + } + + return 1 +} -- cgit v1.2.3