diff --git a/pkg/auth/sender_test.go b/pkg/auth/sender_test.go index b04d5e8b..8eceb22e 100644 --- a/pkg/auth/sender_test.go +++ b/pkg/auth/sender_test.go @@ -105,11 +105,13 @@ func FuzzSender(f *testing.F) { f.Fuzz(func(_ *testing.T, a string) { se, err := NewSender(base.HeaderValue{a}, "myuser", "mypass") - if err == nil { - se.AddAuthorization(&base.Request{ - Method: base.Setup, - URL: mustParseURL("rtsp://myhost/mypath?key=val/trackID=3"), - }) + if err != nil { + return } + + se.AddAuthorization(&base.Request{ + Method: base.Setup, + URL: mustParseURL("rtsp://myhost/mypath?key=val/trackID=3"), + }) }) } diff --git a/pkg/base/body_test.go b/pkg/base/body_test.go index 8446c5ab..56a38bb6 100644 --- a/pkg/base/body_test.go +++ b/pkg/base/body_test.go @@ -54,8 +54,10 @@ func FuzzBodyUnmarshal(f *testing.F) { "Content-Length": HeaderValue{a}, }, bufio.NewReader(bytes.NewReader(b))) - if err == nil { - p.marshal() + if err != nil { + return } + + p.marshal() }) } diff --git a/pkg/base/header_test.go b/pkg/base/header_test.go index 91844439..48660cfa 100644 --- a/pkg/base/header_test.go +++ b/pkg/base/header_test.go @@ -139,8 +139,10 @@ func FuzzHeaderUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var h Header err := h.unmarshal(bufio.NewReader(bytes.NewBuffer(b))) - if err == nil { - h.marshal() + if err != nil { + return } + + h.marshal() }) } diff --git a/pkg/base/interleaved_frame_test.go b/pkg/base/interleaved_frame_test.go index 61a4abef..2828553d 100644 --- a/pkg/base/interleaved_frame_test.go +++ b/pkg/base/interleaved_frame_test.go @@ -58,11 +58,14 @@ func FuzzInterleavedFrameUnmarshal(f *testing.F) { for _, ca := range casesInterleavedFrame { f.Add(ca.enc) } - f.Fuzz(func(_ *testing.T, b []byte) { + f.Fuzz(func(t *testing.T, b []byte) { var f InterleavedFrame err := f.Unmarshal(bufio.NewReader(bytes.NewBuffer(b))) - if err == nil { - f.Marshal() //nolint:errcheck + if err != nil { + return } + + _, err = f.Marshal() + require.NoError(t, err) }) } diff --git a/pkg/base/request_test.go b/pkg/base/request_test.go index ea96e17d..d6123ddc 100644 --- a/pkg/base/request_test.go +++ b/pkg/base/request_test.go @@ -186,11 +186,14 @@ func FuzzRequestUnmarshal(f *testing.F) { f.Add(ca.byts) } - f.Fuzz(func(_ *testing.T, b []byte) { + f.Fuzz(func(t *testing.T, b []byte) { var req Request err := req.Unmarshal(bufio.NewReader(bytes.NewBuffer(b))) - if err == nil { - req.Marshal() //nolint:errcheck + if err != nil { + return } + + _, err = req.Marshal() + require.NoError(t, err) }) } diff --git a/pkg/base/response_test.go b/pkg/base/response_test.go index 5853d836..9d2e73fc 100644 --- a/pkg/base/response_test.go +++ b/pkg/base/response_test.go @@ -160,11 +160,14 @@ func FuzzResponseUnmarshal(f *testing.F) { f.Add(ca.byts) } - f.Fuzz(func(_ *testing.T, b []byte) { + f.Fuzz(func(t *testing.T, b []byte) { var res Response err := res.Unmarshal(bufio.NewReader(bytes.NewBuffer(b))) - if err == nil { - res.Marshal() //nolint:errcheck + if err != nil { + return } + + _, err = res.Marshal() + require.NoError(t, err) }) } diff --git a/pkg/description/session_test.go b/pkg/description/session_test.go index 27d0188d..5db0bcde 100644 --- a/pkg/description/session_test.go +++ b/pkg/description/session_test.go @@ -783,6 +783,7 @@ func FuzzSessionUnmarshal(f *testing.F) { require.NotZero(t, len(desc.Medias)) - desc.Marshal(false) //nolint:errcheck + _, err = desc.Marshal(false) + require.NoError(t, err) }) } diff --git a/pkg/format/rtplpcm/decoder_test.go b/pkg/format/rtplpcm/decoder_test.go index 32aed108..2445b38b 100644 --- a/pkg/format/rtplpcm/decoder_test.go +++ b/pkg/format/rtplpcm/decoder_test.go @@ -31,12 +31,13 @@ func TestDecode(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, b []byte) { + f.Fuzz(func(t *testing.T, b []byte) { d := &Decoder{ BitDepth: 24, ChannelCount: 2, } - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpmjpeg/decoder_test.go b/pkg/format/rtpmjpeg/decoder_test.go index ade2e334..972d8ede 100644 --- a/pkg/format/rtpmjpeg/decoder_test.go +++ b/pkg/format/rtpmjpeg/decoder_test.go @@ -131,9 +131,10 @@ func TestDecodeFixedQuantizationTable(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, am bool, b []byte, bm bool) { + f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) { d := &Decoder{} - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpmpeg1audio/decoder_test.go b/pkg/format/rtpmpeg1audio/decoder_test.go index 312eec7e..1962a610 100644 --- a/pkg/format/rtpmpeg1audio/decoder_test.go +++ b/pkg/format/rtpmpeg1audio/decoder_test.go @@ -27,9 +27,10 @@ func TestDecode(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, b []byte) { + f.Fuzz(func(t *testing.T, a []byte, b []byte) { d := &Decoder{} - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpmpeg1video/decoder_test.go b/pkg/format/rtpmpeg1video/decoder_test.go index 7b6e5b04..3db964c2 100644 --- a/pkg/format/rtpmpeg1video/decoder_test.go +++ b/pkg/format/rtpmpeg1video/decoder_test.go @@ -57,9 +57,10 @@ func TestDecodeErrorMissingPacket(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, b []byte) { + f.Fuzz(func(t *testing.T, a []byte, b []byte) { d := &Decoder{} - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpmpeg4audio/decoder_latm_test.go b/pkg/format/rtpmpeg4audio/decoder_latm_test.go index 1f9cb3f2..c219f707 100644 --- a/pkg/format/rtpmpeg4audio/decoder_latm_test.go +++ b/pkg/format/rtpmpeg4audio/decoder_latm_test.go @@ -104,11 +104,12 @@ func TestDecodeLATMErrorMissingPacket(t *testing.T) { } func FuzzDecoderLATM(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, am bool, b []byte, bm bool) { + f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) { d := &Decoder{ LATM: true, } - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpmpeg4video/decoder_test.go b/pkg/format/rtpmpeg4video/decoder_test.go index c7d56316..54f62d0d 100644 --- a/pkg/format/rtpmpeg4video/decoder_test.go +++ b/pkg/format/rtpmpeg4video/decoder_test.go @@ -62,9 +62,10 @@ func TestDecodeErrorMissingPacket(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, am bool, b []byte, bm bool) { + f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) { d := &Decoder{} - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpvp8/decoder_test.go b/pkg/format/rtpvp8/decoder_test.go index 973e9fda..17badd2d 100644 --- a/pkg/format/rtpvp8/decoder_test.go +++ b/pkg/format/rtpvp8/decoder_test.go @@ -58,9 +58,10 @@ func TestDecodeErrorMissingPacket(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, am bool, b []byte, bm bool) { + f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) { d := &Decoder{} - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/format/rtpvp9/decoder_test.go b/pkg/format/rtpvp9/decoder_test.go index 6581b8e4..fb493f69 100644 --- a/pkg/format/rtpvp9/decoder_test.go +++ b/pkg/format/rtpvp9/decoder_test.go @@ -66,9 +66,10 @@ func TestDecodeErrorMissingPacket(t *testing.T) { } func FuzzDecoder(f *testing.F) { - f.Fuzz(func(_ *testing.T, a []byte, am bool, b []byte, bm bool) { + f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) { d := &Decoder{} - d.Init() //nolint:errcheck + err := d.Init() + require.NoError(t, err) d.Decode(&rtp.Packet{ //nolint:errcheck Header: rtp.Header{ diff --git a/pkg/headers/authenticate_test.go b/pkg/headers/authenticate_test.go index 010b4cf3..9a12f648 100644 --- a/pkg/headers/authenticate_test.go +++ b/pkg/headers/authenticate_test.go @@ -135,9 +135,11 @@ func FuzzAuthenticateUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b string) { var h Authenticate err := h.Unmarshal(base.HeaderValue{b}) - if err == nil { - h.Marshal() + if err != nil { + return } + + h.Marshal() }) } diff --git a/pkg/headers/authorization_test.go b/pkg/headers/authorization_test.go index 31a5b189..16114599 100644 --- a/pkg/headers/authorization_test.go +++ b/pkg/headers/authorization_test.go @@ -132,9 +132,11 @@ func FuzzAuthorizationUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b string) { var h Authorization err := h.Unmarshal(base.HeaderValue{b}) - if err == nil { - h.Marshal() + if err != nil { + return } + + h.Marshal() }) } diff --git a/pkg/headers/range_test.go b/pkg/headers/range_test.go index 48460a70..35d4756f 100644 --- a/pkg/headers/range_test.go +++ b/pkg/headers/range_test.go @@ -152,9 +152,11 @@ func FuzzRangeUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b string) { var h Range err := h.Unmarshal(base.HeaderValue{b}) - if err == nil { - h.Marshal() + if err != nil { + return } + + h.Marshal() }) } diff --git a/pkg/headers/rtpinfo_test.go b/pkg/headers/rtpinfo_test.go index 9ce8abb2..0424f6a7 100644 --- a/pkg/headers/rtpinfo_test.go +++ b/pkg/headers/rtpinfo_test.go @@ -159,9 +159,11 @@ func FuzzRTPInfoUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b string) { var h RTPInfo err := h.Unmarshal(base.HeaderValue{b}) - if err == nil { - h.Marshal() + if err != nil { + return } + + h.Marshal() }) } diff --git a/pkg/headers/session_test.go b/pkg/headers/session_test.go index bb340f6a..47aebb5c 100644 --- a/pkg/headers/session_test.go +++ b/pkg/headers/session_test.go @@ -72,9 +72,11 @@ func FuzzSessionUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b string) { var h Session err := h.Unmarshal(base.HeaderValue{b}) - if err == nil { - h.Marshal() + if err != nil { + return } + + h.Marshal() }) } diff --git a/pkg/headers/transport_test.go b/pkg/headers/transport_test.go index e12b7fb0..dcf7b0d3 100644 --- a/pkg/headers/transport_test.go +++ b/pkg/headers/transport_test.go @@ -257,9 +257,11 @@ func FuzzTransportsUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b string) { var h Transports err := h.Unmarshal(base.HeaderValue{b}) - if err == nil { - h.Marshal() + if err != nil { + return } + + h.Marshal() }) } diff --git a/pkg/sdp/sdp_test.go b/pkg/sdp/sdp_test.go index 4e72aa46..dba958aa 100644 --- a/pkg/sdp/sdp_test.go +++ b/pkg/sdp/sdp_test.go @@ -3226,11 +3226,14 @@ func FuzzUnmarshal(f *testing.F) { f.Add(string(c.enc)) } - f.Fuzz(func(_ *testing.T, b string) { + f.Fuzz(func(t *testing.T, b string) { var desc SessionDescription err := desc.Unmarshal([]byte(b)) - if err == nil { - desc.Marshal() //nolint:errcheck + if err != nil { + return } + + _, err = desc.Marshal() + require.NoError(t, err) }) }