summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/sdp/v3/fuzz.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/pion/sdp/v3/fuzz.go')
-rw-r--r--vendor/github.com/pion/sdp/v3/fuzz.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/github.com/pion/sdp/v3/fuzz.go b/vendor/github.com/pion/sdp/v3/fuzz.go
new file mode 100644
index 0000000..f41ef78
--- /dev/null
+++ b/vendor/github.com/pion/sdp/v3/fuzz.go
@@ -0,0 +1,31 @@
+// +build gofuzz
+
+package sdp
+
+// Fuzz implements a randomized fuzz test of the sdp
+// 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`
+//
+// And run the fuzzer on the corpus:
+// `go-fuzz`
+func Fuzz(data []byte) int {
+ // Check that unmarshalling any byte slice does not panic.
+ var sd SessionDescription
+ if err := sd.Unmarshal(data); err != nil {
+ return 0
+ }
+ // Check that we can marshal anything we unmarshalled.
+ _, err := sd.Marshal()
+ if err != nil {
+ panic("failed to marshal") // nolint
+ }
+ // It'd be nice to check that if we round trip Marshal then Unmarshal,
+ // we get the original back. Right now, though, we frequently don't,
+ // and we'd need to fix that first.
+ return 1
+}