mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 23:52:46 +08:00
prevent decoders from emitting corrupted frames (#638)
This commit is contained in:
@@ -38,6 +38,40 @@ func TestDecode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeErrorMissingPacket(t *testing.T) {
|
||||
d := &Decoder{}
|
||||
err := d.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = d.Decode(&rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: false,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17645,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: []byte{
|
||||
0x01, 0x02, 0x0b, 0x77, 0x1a, 0x01, 0x1e, 0x40,
|
||||
},
|
||||
})
|
||||
require.Equal(t, ErrMorePacketsNeeded, err)
|
||||
|
||||
_, err = d.Decode(&rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: false,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17647,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: []byte{
|
||||
0x03, 0x02, 0x72, 0xdc, 0x06, 0x7d, 0x2d, 0xe5,
|
||||
},
|
||||
})
|
||||
require.EqualError(t, err, "discarding frame since a RTP packet is missing")
|
||||
}
|
||||
|
||||
func FuzzDecoder(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) {
|
||||
d := &Decoder{}
|
||||
|
Reference in New Issue
Block a user