diff --git a/pkg/codecs/ac3/bsi_test.go b/pkg/codecs/ac3/bsi_test.go index 05db08f..ac95284 100644 --- a/pkg/codecs/ac3/bsi_test.go +++ b/pkg/codecs/ac3/bsi_test.go @@ -24,6 +24,9 @@ func FuzzBSIUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var bsi BSI - bsi.Unmarshal(b) //nolint:errcheck + err := bsi.Unmarshal(b) + if err == nil { + bsi.ChannelCount() //nolint:staticcheck + } }) } diff --git a/pkg/codecs/ac3/sync_info_test.go b/pkg/codecs/ac3/sync_info_test.go index 8de314b..ca2fdbf 100644 --- a/pkg/codecs/ac3/sync_info_test.go +++ b/pkg/codecs/ac3/sync_info_test.go @@ -333,6 +333,10 @@ func FuzzSyncInfoUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var syncInfo SyncInfo - syncInfo.Unmarshal(b) //nolint:errcheck + err := syncInfo.Unmarshal(b) + if err == nil { + syncInfo.FrameSize() + syncInfo.SampleRate() //nolint:staticcheck + } }) } diff --git a/pkg/codecs/av1/bitstream_test.go b/pkg/codecs/av1/bitstream_test.go index 530bceb..4013863 100644 --- a/pkg/codecs/av1/bitstream_test.go +++ b/pkg/codecs/av1/bitstream_test.go @@ -58,6 +58,9 @@ func FuzzBitstreamUnmarshal(f *testing.F) { } f.Fuzz(func(_ *testing.T, b []byte) { - BitstreamUnmarshal(b, true) //nolint:errcheck + tu, err := BitstreamUnmarshal(b, true) + if err == nil { + BitstreamMarshal(tu) //nolint:errcheck + } }) } diff --git a/pkg/codecs/av1/leb128_test.go b/pkg/codecs/av1/leb128_test.go index 2c6c440..ef3f907 100644 --- a/pkg/codecs/av1/leb128_test.go +++ b/pkg/codecs/av1/leb128_test.go @@ -56,6 +56,10 @@ func FuzzLEB128Unmarshal(f *testing.F) { } f.Fuzz(func(_ *testing.T, b []byte) { - LEB128Unmarshal(b) //nolint:errcheck + v, _, err := LEB128Unmarshal(b) + if err == nil { + enc := make([]byte, LEB128MarshalSize(v)) + LEB128MarshalTo(v, enc) + } }) } diff --git a/pkg/codecs/av1/sequence_header_test.go b/pkg/codecs/av1/sequence_header_test.go index a695d4f..efd7f6a 100644 --- a/pkg/codecs/av1/sequence_header_test.go +++ b/pkg/codecs/av1/sequence_header_test.go @@ -145,6 +145,10 @@ func FuzzSequenceHeaderUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var sh SequenceHeader - sh.Unmarshal(b) //nolint:errcheck + err := sh.Unmarshal(b) + if err == nil { + sh.Width() + sh.Height() + } }) } diff --git a/pkg/codecs/h264/annexb_test.go b/pkg/codecs/h264/annexb_test.go index dfebad2..6bfc24c 100644 --- a/pkg/codecs/h264/annexb_test.go +++ b/pkg/codecs/h264/annexb_test.go @@ -134,6 +134,9 @@ func FuzzAnnexBUnmarshal(f *testing.F) { } f.Fuzz(func(_ *testing.T, b []byte) { - AnnexBUnmarshal(b) //nolint:errcheck + au, err := AnnexBUnmarshal(b) + if err == nil { + AnnexBMarshal(au) //nolint:errcheck + } }) } diff --git a/pkg/codecs/h264/avcc_test.go b/pkg/codecs/h264/avcc_test.go index 82721f5..2e93c9a 100644 --- a/pkg/codecs/h264/avcc_test.go +++ b/pkg/codecs/h264/avcc_test.go @@ -84,6 +84,9 @@ func FuzzAVCCUnmarshal(f *testing.F) { } f.Fuzz(func(_ *testing.T, b []byte) { - AVCCUnmarshal(b) //nolint:errcheck + au, err := AVCCUnmarshal(b) + if err == nil { + AVCCMarshal(au) //nolint:errcheck + } }) } diff --git a/pkg/codecs/h264/sps_test.go b/pkg/codecs/h264/sps_test.go index 176924a..87fff2f 100644 --- a/pkg/codecs/h264/sps_test.go +++ b/pkg/codecs/h264/sps_test.go @@ -518,6 +518,11 @@ func FuzzSPSUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var sps SPS - sps.Unmarshal(b) //nolint:errcheck + err := sps.Unmarshal(b) //nolint:errcheck + if err == nil { + sps.Width() + sps.Height() + sps.FPS() + } }) } diff --git a/pkg/codecs/h265/sps_test.go b/pkg/codecs/h265/sps_test.go index 32bee2e..ef88c9c 100644 --- a/pkg/codecs/h265/sps_test.go +++ b/pkg/codecs/h265/sps_test.go @@ -566,6 +566,11 @@ func FuzzSPSUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var sps SPS - sps.Unmarshal(b) //nolint:errcheck + err := sps.Unmarshal(b) + if err == nil { + sps.Width() + sps.Height() + sps.FPS() + } }) } diff --git a/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/0b49c30960e29a34 b/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/0b49c30960e29a34 new file mode 100644 index 0000000..c3e583c --- /dev/null +++ b/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/0b49c30960e29a34 @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("B000000000000000\xff\xffX000$8") diff --git a/pkg/codecs/mpeg1audio/frame_header_test.go b/pkg/codecs/mpeg1audio/frame_header_test.go index 22a8a72..f3a4d55 100644 --- a/pkg/codecs/mpeg1audio/frame_header_test.go +++ b/pkg/codecs/mpeg1audio/frame_header_test.go @@ -121,6 +121,10 @@ func FuzzFrameHeaderUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var h FrameHeader - h.Unmarshal(b) //nolint:errcheck + err := h.Unmarshal(b) + if err == nil { + h.FrameLen() //nolint:staticcheck + h.SampleCount() //nolint:staticcheck + } }) } diff --git a/pkg/codecs/mpeg4audio/adts.go b/pkg/codecs/mpeg4audio/adts.go index dfb5dd3..499bf2c 100644 --- a/pkg/codecs/mpeg4audio/adts.go +++ b/pkg/codecs/mpeg4audio/adts.go @@ -4,7 +4,7 @@ import ( "fmt" ) -// ADTSPacket is an ADTS frame. +// ADTSPacket is an ADTS packet. // Specification: ISO 14496-3, Table 1.A.5 type ADTSPacket struct { Type ObjectType @@ -13,7 +13,7 @@ type ADTSPacket struct { AU []byte } -// ADTSPackets is a group od ADTS packets. +// ADTSPackets is a group of ADTS packets. type ADTSPackets []*ADTSPacket // Unmarshal decodes an ADTS stream into ADTS packets. diff --git a/pkg/codecs/mpeg4audio/adts_test.go b/pkg/codecs/mpeg4audio/adts_test.go index 916efb0..07dae1b 100644 --- a/pkg/codecs/mpeg4audio/adts_test.go +++ b/pkg/codecs/mpeg4audio/adts_test.go @@ -75,6 +75,9 @@ func FuzzADTSUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var pkts ADTSPackets - pkts.Unmarshal(b) //nolint:errcheck + err := pkts.Unmarshal(b) + if err == nil { + pkts.Marshal() //nolint:errcheck + } }) } diff --git a/pkg/codecs/mpeg4audio/audio_specific_config_test.go b/pkg/codecs/mpeg4audio/audio_specific_config_test.go index 6a3d34c..5acd2d2 100644 --- a/pkg/codecs/mpeg4audio/audio_specific_config_test.go +++ b/pkg/codecs/mpeg4audio/audio_specific_config_test.go @@ -148,6 +148,9 @@ func FuzzAudioSpecificConfigUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var conf AudioSpecificConfig - conf.Unmarshal(b) //nolint:errcheck + err := conf.Unmarshal(b) + if err == nil { + conf.Marshal() //nolint:errcheck + } }) } diff --git a/pkg/codecs/mpeg4audio/stream_mux_config_test.go b/pkg/codecs/mpeg4audio/stream_mux_config_test.go index 1c09c08..e1dedd1 100644 --- a/pkg/codecs/mpeg4audio/stream_mux_config_test.go +++ b/pkg/codecs/mpeg4audio/stream_mux_config_test.go @@ -167,6 +167,9 @@ func FuzzStreamMuxConfigUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var conf StreamMuxConfig - conf.Unmarshal(b) //nolint:errcheck + err := conf.Unmarshal(b) + if err == nil { + conf.Marshal() //nolint:errcheck + } }) } diff --git a/pkg/codecs/mpeg4audio/testdata/fuzz/FuzzStreamMuxConfigUnmarshal/c5df9d46cc267ff5 b/pkg/codecs/mpeg4audio/testdata/fuzz/FuzzStreamMuxConfigUnmarshal/c5df9d46cc267ff5 new file mode 100644 index 0000000..dfe6d6f --- /dev/null +++ b/pkg/codecs/mpeg4audio/testdata/fuzz/FuzzStreamMuxConfigUnmarshal/c5df9d46cc267ff5 @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("A0 70005") diff --git a/pkg/codecs/mpeg4audio/testdata/fuzz/FuzzStreamMuxConfigUnmarshal/e68126ba668e153d b/pkg/codecs/mpeg4audio/testdata/fuzz/FuzzStreamMuxConfigUnmarshal/e68126ba668e153d new file mode 100644 index 0000000..435b3d7 --- /dev/null +++ b/pkg/codecs/mpeg4audio/testdata/fuzz/FuzzStreamMuxConfigUnmarshal/e68126ba668e153d @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("A0 0\xa5") diff --git a/pkg/formats/fmp4/init_test.go b/pkg/formats/fmp4/init_test.go index 7440bed..c3d8ae9 100644 --- a/pkg/formats/fmp4/init_test.go +++ b/pkg/formats/fmp4/init_test.go @@ -2134,7 +2134,11 @@ func FuzzInitUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var init Init - init.Unmarshal(bytes.NewReader(b)) //nolint:errcheck + err := init.Unmarshal(bytes.NewReader(b)) + if err == nil { + var buf seekablebuffer.Buffer + init.Marshal(&buf) //nolint:errcheck + } }) } diff --git a/pkg/formats/fmp4/parts_test.go b/pkg/formats/fmp4/parts_test.go index 609b755..0cd0681 100644 --- a/pkg/formats/fmp4/parts_test.go +++ b/pkg/formats/fmp4/parts_test.go @@ -181,7 +181,11 @@ func FuzzPartsUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var parts Parts - parts.Unmarshal(b) //nolint:errcheck + err := parts.Unmarshal(b) + if err == nil { + var buf seekablebuffer.Buffer + parts.Marshal(&buf) //nolint:errcheck + } }) } diff --git a/pkg/formats/fmp4/testdata/fuzz/FuzzPartsUnmarshal/e9b2aa3473056adc b/pkg/formats/fmp4/testdata/fuzz/FuzzPartsUnmarshal/e9b2aa3473056adc new file mode 100644 index 0000000..cfd0b76 --- /dev/null +++ b/pkg/formats/fmp4/testdata/fuzz/FuzzPartsUnmarshal/e9b2aa3473056adc @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("\x00\x00\x00`moof\x00\x00\x00\x10mfhd\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00Htraf\x00\x00\x00\x10tfhd\x00\x02\x00\x00\x00\x00\x00d\x00\x00\x00\x14tfdt\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01_\x90\x00\x00\x00\x1ctrun\x00\x00\x00\n\\dat\x01h") diff --git a/pkg/formats/mpegts/opus_access_unit_test.go b/pkg/formats/mpegts/opus_access_unit_test.go index 46bc2a3..ff340ca 100644 --- a/pkg/formats/mpegts/opus_access_unit_test.go +++ b/pkg/formats/mpegts/opus_access_unit_test.go @@ -82,6 +82,10 @@ func FuzzOpusAccessUnitUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var h opusAccessUnit - h.unmarshal(b) //nolint:errcheck + _, err := h.unmarshal(b) //nolint:errcheck + if err == nil { + buf := make([]byte, h.marshalSize()) + h.marshalTo(buf) //nolint:errcheck + } }) } diff --git a/pkg/formats/mpegts/opus_control_header_test.go b/pkg/formats/mpegts/opus_control_header_test.go index cb0ebd8..5bbff46 100644 --- a/pkg/formats/mpegts/opus_control_header_test.go +++ b/pkg/formats/mpegts/opus_control_header_test.go @@ -142,6 +142,10 @@ func FuzzOpusControlHeaderUnmarshal(f *testing.F) { f.Fuzz(func(_ *testing.T, b []byte) { var h opusControlHeader - h.unmarshal(b) //nolint:errcheck + _, err := h.unmarshal(b) + if err == nil { + buf := make([]byte, h.marshalSize()) + h.marshalTo(buf) //nolint:errcheck + } }) }