Skip to content

Commit c3b3847

Browse files
committed
Added TryMarshalUnmarshal for fuzzers
Fuzzers need some public function to perform their work.
1 parent 553d34c commit c3b3847

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packet.go

+16
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,19 @@ func (p *packet) String() string {
209209
}
210210
return res
211211
}
212+
213+
// TryMarshalUnmarshal attempts to marshal and unmarshal a message. Added for fuzzing.
214+
func TryMarshalUnmarshal(msg []byte) int {
215+
p := &packet{}
216+
err := p.unmarshal(false, msg)
217+
if err != nil {
218+
return 0
219+
}
220+
221+
_, err = p.marshal(false)
222+
if err != nil {
223+
return 0
224+
}
225+
226+
return 1
227+
}

0 commit comments

Comments
 (0)