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 d73e46d
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

Check warning on line 218 in packet.go

View check run for this annotation

Codecov / codecov/patch

packet.go#L214-L218

Added lines #L214 - L218 were not covered by tests
}

_, err = p.marshal(false)
if err != nil {
return 0

Check warning on line 223 in packet.go

View check run for this annotation

Codecov / codecov/patch

packet.go#L221-L223

Added lines #L221 - L223 were not covered by tests
}

return 1

Check warning on line 226 in packet.go

View check run for this annotation

Codecov / codecov/patch

packet.go#L226

Added line #L226 was not covered by tests
}

0 comments on commit d73e46d

Please sign in to comment.