diff --git a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc index 37df7d254a..08743b3b2a 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc @@ -45,6 +45,11 @@ namespace webrtc { namespace ModuleRTPUtility { +enum { + kRtcpMinHeaderLength = 4, + kRtcpExpectedVersion = 2 +}; + /* * Time routines. */ @@ -269,11 +274,18 @@ bool RTPHeaderParser::RTCP() const { * FMT 15: Application layer FB message */ + const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin; + if (length < kRtcpMinHeaderLength) { + return false; + } + + const WebRtc_UWord8 V = _ptrRTPDataBegin[0] >> 6; + if (V != kRtcpExpectedVersion) { + return false; + } + const WebRtc_UWord8 payloadType = _ptrRTPDataBegin[1]; - bool RTCP = false; - - // check if this is a RTCP packet switch (payloadType) { case 192: RTCP = true;