Skip to content

Commit

Permalink
Added TryMarshalUnmarshal for fuzzers
Browse files Browse the repository at this point in the history
Fuzzers need some public function to perform their work.
  • Loading branch information
sirzooro committed Jul 6, 2024
1 parent 553d34c commit c3b3847
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c3b3847

Please sign in to comment.