mirror of
https://github.com/aler9/gortsplib
synced 2025-10-07 16:10:59 +08:00
prevent decoders from emitting corrupted frames (#638)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package rtpmpeg4audio
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
@@ -70,6 +71,46 @@ func TestDecodeGenericADTS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeGenericErrorMissingPacket(t *testing.T) {
|
||||
d := &Decoder{
|
||||
SizeLength: 13,
|
||||
IndexLength: 3,
|
||||
IndexDeltaLength: 3,
|
||||
}
|
||||
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: mergeBytes(
|
||||
[]byte{0x0, 0x10, 0x2d, 0x80},
|
||||
bytes.Repeat([]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, 182),
|
||||
),
|
||||
})
|
||||
require.Equal(t, ErrMorePacketsNeeded, err)
|
||||
|
||||
_, err = d.Decode(&rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: false,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17647,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: mergeBytes(
|
||||
[]byte{0x00, 0x10, 0x2d, 0x80},
|
||||
bytes.Repeat([]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, 182),
|
||||
),
|
||||
})
|
||||
require.EqualError(t, err, "discarding frame since a RTP packet is missing")
|
||||
}
|
||||
|
||||
func FuzzDecoderGeneric(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