From dea075c7a6bee96f319192f7beca03ef76fc0500 Mon Sep 17 00:00:00 2001 From: eladalon Date: Tue, 13 Jun 2017 07:57:31 -0700 Subject: [PATCH] Log an error in RtpDemuxer::FindSsrcAssociations() if kMaxProcessedSsrcs exceeded BUG=None Review-Url: https://codereview.webrtc.org/2941513002 Cr-Commit-Position: refs/heads/master@{#18569} --- webrtc/call/rtp_demuxer.cc | 8 +++++++- webrtc/call/rtp_demuxer.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/webrtc/call/rtp_demuxer.cc b/webrtc/call/rtp_demuxer.cc index b2c9510cca..620d4b17a9 100644 --- a/webrtc/call/rtp_demuxer.cc +++ b/webrtc/call/rtp_demuxer.cc @@ -8,8 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/base/checks.h" #include "webrtc/call/rtp_demuxer.h" + +#include "webrtc/base/checks.h" +#include "webrtc/base/logging.h" #include "webrtc/call/rtp_packet_sink_interface.h" #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" @@ -118,6 +120,10 @@ void RtpDemuxer::FindSsrcAssociations(const RtpPacketReceived& packet) { if (processed_ssrcs_.size() < kMaxProcessedSsrcs) { // Prevent memory overuse processed_ssrcs_.insert(packet.Ssrc()); // Avoid re-examining in-depth. + } else if (!logged_max_processed_ssrcs_exceeded_) { + LOG(LS_WARNING) << "More than " << kMaxProcessedSsrcs + << " different SSRCs seen."; + logged_max_processed_ssrcs_exceeded_ = true; } } diff --git a/webrtc/call/rtp_demuxer.h b/webrtc/call/rtp_demuxer.h index a5ba889a03..6a4370d731 100644 --- a/webrtc/call/rtp_demuxer.h +++ b/webrtc/call/rtp_demuxer.h @@ -70,6 +70,9 @@ class RtpDemuxer { // check RSIDs for the first packet on each incoming SSRC stream. // (If RSID associations are added later, we check again.) std::set processed_ssrcs_; + + // Avoid an attack that would create excessive logging. + bool logged_max_processed_ssrcs_exceeded_ = false; }; } // namespace webrtc