diff --git a/packet.go b/packet.go index 72660f3e..a2ab8e14 100644 --- a/packet.go +++ b/packet.go @@ -209,3 +209,19 @@ func (p *packet) String() string { } return res } + +// TryMarshalUnmarshal attempts to marshal and unmarshal a message. Added for fuzzing. +func TryMarshalUnmarshal(msg []byte) int { + p := &packet{} + err := p.unmarshal(false, msg) + if err != nil { + return 0 + } + + _, err = p.marshal(false) + if err != nil { + return 0 + } + + return 1 +}