mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
prevent decoders from returning empty NALUs (bluenviron/mediamtx#4346) (#726)
This commit is contained in:
@@ -275,32 +275,39 @@ 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, 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
|
||||
au, err := d.Decode(&rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: false,
|
||||
PayloadType: 96,
|
||||
Marker: am,
|
||||
SequenceNumber: 17645,
|
||||
Timestamp: 2289527317,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: a,
|
||||
})
|
||||
|
||||
d.Decode(&rtp.Packet{ //nolint:errcheck
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: false,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17645,
|
||||
Timestamp: 2289527317,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: b,
|
||||
})
|
||||
if errors.Is(err, ErrMorePacketsNeeded) {
|
||||
au, err = d.Decode(&rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Marker: bm,
|
||||
SequenceNumber: 17646,
|
||||
},
|
||||
Payload: b,
|
||||
})
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
if len(au) == 0 {
|
||||
t.Errorf("should not happen")
|
||||
}
|
||||
|
||||
for _, nalu := range au {
|
||||
if len(nalu) == 0 {
|
||||
t.Errorf("should not happen")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user