From 117e95fc4c42ca6508fd041163223bbcbc06b0b0 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 9 Dec 2021 16:40:12 +0000 Subject: [PATCH] Tolerate overlong MID in channel.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The matcher layer tolerates MIDs only up to 16, but the parser polices a limit of 32 (due to users using this in ways that do not create a matcher). Tolerate the MID instead of crashing. Bug: webrtc:12517 Change-Id: I67ac4a7fa53c918b271b5a3020f497c9d60ec6f5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240521 Reviewed-by: Philipp Hancke Reviewed-by: Henrik Boström Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#35513} --- pc/channel.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pc/channel.cc b/pc/channel.cc index 9e113c819f..b85122d922 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -133,7 +133,16 @@ BaseChannel::BaseChannel(rtc::Thread* worker_thread, ssrc_generator_(ssrc_generator) { RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK(ssrc_generator_); - demuxer_criteria_.mid = content_name; + // Temp fix: MID in SDP is allowed to be slightly longer than what's allowed + // in the RTP demuxer. Truncate if needed; this won't match, but it only + // makes sense in places that wouldn't use this for matching anyway. + // TODO(bugs.webrtc.org/12517): remove when length 16 is policed by parser. + if (content_name.size() > 16) { + RTC_LOG(LS_ERROR) << "Overlong mid attribute, truncating for matching"; + demuxer_criteria_.mid = content_name.substr(0, 16); + } else { + demuxer_criteria_.mid = content_name; + } RTC_LOG(LS_INFO) << "Created channel: " << ToString(); }