Tolerate overlong MID in channel.cc

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 <philipp.hancke@googlemail.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35513}
This commit is contained in:
Harald Alvestrand
2021-12-09 16:40:12 +00:00
committed by WebRTC LUCI CQ
parent 1c78c41724
commit 117e95fc4c

View File

@ -133,7 +133,16 @@ BaseChannel::BaseChannel(rtc::Thread* worker_thread,
ssrc_generator_(ssrc_generator) {
RTC_DCHECK_RUN_ON(worker_thread_);
RTC_DCHECK(ssrc_generator_);
// 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();
}