From 063bb384f8d15cfeb183c12ddd623a25dc822a35 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Mon, 29 Nov 2021 12:05:38 +0100 Subject: [PATCH] sdp: temporarily raise mid limit to 32 to avoid breaking existing deployments. Also measure usage. BUG=webrtc:12517 Change-Id: Ic38f1b45e79e46da9ff6fe927b0c5351443ccd96 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/239188 Reviewed-by: Harald Alvestrand Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/main@{#35445} --- pc/peer_connection_signaling_unittest.cc | 2 +- pc/sdp_offer_answer.cc | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index 8df90b7bfa..250efc8dc5 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -1051,7 +1051,7 @@ TEST_P(PeerConnectionSignalingTest, MidAttributeMaxLength) { "1C:2C:74:01:8D:50:67:23\r\n" "a=setup:actpass\r\n" // Too long mid attribute. - "a=mid:01234567890123456\r\n" + "a=mid:0123456789012345678901234567890123\r\n" "a=sendrecv\r\n" "a=msid:stream track\r\n" "a=rtcp-mux\r\n" diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 8f5cec2f03..4332cd6df8 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -124,7 +124,8 @@ const char kSimulcastDisabled[] = "WebRTC.PeerConnection.Simulcast.Disabled"; static const int kRtcpCnameLength = 16; // The maximum length of the MID attribute. -static constexpr size_t kMidMaxSize = 16; +// TODO(bugs.webrtc.org/12517) - reduce to 16 again. +static constexpr size_t kMidMaxSize = 32; const char kDefaultStreamId[] = "default"; // NOTE: Duplicated in peer_connection.cc: @@ -446,21 +447,25 @@ bool VerifyIceUfragPwdPresent( RTCError ValidateMids(const cricket::SessionDescription& description) { std::set mids; + size_t max_length = 0; for (const cricket::ContentInfo& content : description.contents()) { if (content.name.empty()) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "A media section is missing a MID attribute."); } + max_length = std::max(max_length, content.name.size()); if (content.name.size() > kMidMaxSize) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "The MID attribute exceeds the maximum supported " - "length of 16 characters."); + "length of 32 characters."); } if (!mids.insert(content.name).second) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "Duplicate a=mid value '" + content.name + "'."); } } + RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.PeerConnection.Mid.Size", max_length, 0, + 31, 32); return RTCError::OK(); }