Skip to content

Commit

Permalink
Merge pull request #96 from negbie/master
Browse files Browse the repository at this point in the history
Fix bug found by fuzzer
  • Loading branch information
negbie committed Dec 7, 2018
2 parents 4def387 + 058ff2c commit 0df024d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions protos/fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// +build gofuzz

package protos

// 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/negbie/heplify/protos
//
// And run the fuzzer
//
// go-fuzz -bin=fuzz-protos.zip -workdir=workdir

func Fuzz(data []byte) int {
ParseRTCP(data)
return 0
}
2 changes: 1 addition & 1 deletion protos/rtcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func ParseRTCP(data []byte) (ssrcBytes []byte, rtcpPkt []byte, infoMsg string) {
offset := 0

for dataLen > 0 {
if dataLen < 4 || dataLen > 576 || offset >= len(data) {
if dataLen < 4 || dataLen > 768 || offset > len(data)-4 {
infoMsg = fmt.Sprintf("Fishy RTCP dataLen=%d, offset=%d in packet:\n% X", dataLen, offset, data)
break
}
Expand Down

0 comments on commit 0df024d

Please sign in to comment.