History

rtpdec: Read the packet length for all RTCP packet types

This allows skipping past unsupported RTCP packet types, as RFC 3550 section 6.1 mandates. Currently this only has any practical effect if a sender puts an unrecognized type before RTCP_BYE in a compounded packet, or (incorrectly) does not put RTCP_SR first.

John Brooks committed 15 years ago

Commit 07b77fe1 parent 5d6ecf51 file · +7 −7Browse files

Unified · Split

libavformat/rtpdec.c+7−7
@@ -112,14 +112,15 @@ RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id, · 111 unmodified lines
112112 static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len)
113113 {
114114 int payload_len;
115− while (len >= 2) {
115+ while (len >= 4) {
116+ payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4);
117+
116118 switch (buf[1]) {
117119 case RTCP_SR:
118− if (len < 20) {
120+ if (payload_len < 20) {
119121 av_log(NULL, AV_LOG_ERROR, "Invalid length for RTCP SR packet\n");
120122 return AVERROR_INVALIDDATA;
121123 }
122− payload_len = (AV_RB16(buf + 2) + 1) * 4;
123124
124125 s->last_rtcp_ntp_time = AV_RB64(buf + 8);
125126 s->last_rtcp_timestamp = AV_RB32(buf + 16);
@@ -130,14 +131,13 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l · 4 unmodified lines
130131 s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp;
131132 }
132133
133− buf += payload_len;
134− len -= payload_len;
135134 break;
136135 case RTCP_BYE:
137136 return -RTCP_BYE;
138− default:
139− return -1;
140137 }
138+
139+ buf += payload_len;
140+ len -= payload_len;
141141 }
142142 return -1;
143143 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t