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 739bf8b commit 380a58b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,18 @@ func parseExpectDataChannelOpen(raw []byte) (*channelOpen, error) {

return msg, nil
}

// TryMarshalUnmarshal attempts to marshal and unmarshal a message. Added for fuzzing.
func TryMarshalUnmarshal(msg []byte) int {
message, err := parse(msg)
if err != nil {
return 0
}

_, err = message.Marshal()
if err != nil {
return 0
}

return 1
}

0 comments on commit 380a58b

Please sign in to comment.