diff --git a/pkg/sdp/sdp.go b/pkg/sdp/sdp.go index 63ca2b54..31f02f10 100644 --- a/pkg/sdp/sdp.go +++ b/pkg/sdp/sdp.go @@ -682,7 +682,11 @@ func (s *SessionDescription) Unmarshal(byts []byte) error { state = stateSession default: - return fmt.Errorf("invalid key: %c (%s)", key, line) + state = stateSession + err := s.unmarshalSession(&state, key, val) + if err != nil { + return err + } } case stateSession: diff --git a/pkg/sdp/sdp_test.go b/pkg/sdp/sdp_test.go index 509641e6..c535b339 100644 --- a/pkg/sdp/sdp_test.go +++ b/pkg/sdp/sdp_test.go @@ -2525,6 +2525,36 @@ var cases = []struct { }, }, }, + { + "issue gortsplib/448", + []byte("m=video 0 RTP/AVP 96\r\n" + + "a=rtpmap:96 H264/90000\r\n" + + "a=control:trackID=0\r\n"), + []byte("v=0\r\n" + + "o= 0 0 \r\n" + + "m=video 0 RTP/AVP 96\r\n" + + "a=rtpmap:96 H264/90000\r\n" + + "a=control:trackID=0\r\n"), + SessionDescription{ + MediaDescriptions: []*psdp.MediaDescription{{ + MediaName: psdp.MediaName{ + Media: "video", + Protos: []string{"RTP", "AVP"}, + Formats: []string{"96"}, + }, + Attributes: []psdp.Attribute{ + { + Key: "rtpmap", + Value: "96 H264/90000", + }, + { + Key: "control", + Value: "trackID=0", + }, + }, + }}, + }, + }, } func TestUnmarshal(t *testing.T) { diff --git a/pkg/sdp/testdata/fuzz/FuzzUnmarshal/2fe9aff6f8340ce4 b/pkg/sdp/testdata/fuzz/FuzzUnmarshal/2fe9aff6f8340ce4 new file mode 100644 index 00000000..4a1865bb --- /dev/null +++ b/pkg/sdp/testdata/fuzz/FuzzUnmarshal/2fe9aff6f8340ce4 @@ -0,0 +1,2 @@ +go test fuzz v1 +string("0=")