sdp: limit mid attribute to 16 characters

removing the temporary limitation to 32 characters
since metrics suggests this is now fixed.

Metrics removal:
  https://chromium-review.googlesource.com/c/chromium/src/+/4079261

BUG=webrtc:12517,chromium:1375724

Change-Id: I11bec89463044afa99eeef2b3ecbe108eaa5c954
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286620
Reviewed-by: Johannes Kron <kron@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38836}
This commit is contained in:
Philipp Hancke 2022-12-07 11:49:31 +01:00 committed by WebRTC LUCI CQ
parent 100de33983
commit e2652e168a
2 changed files with 28 additions and 7 deletions

View File

@ -120,8 +120,7 @@ const char kSimulcastDisabled[] = "WebRTC.PeerConnection.Simulcast.Disabled";
static const int kRtcpCnameLength = 16;
// The maximum length of the MID attribute.
// TODO(bugs.webrtc.org/12517) - reduce to 16 again.
static constexpr size_t kMidMaxSize = 32;
static constexpr size_t kMidMaxSize = 16;
const char kDefaultStreamId[] = "default";
// NOTE: Duplicated in peer_connection.cc:
@ -408,25 +407,21 @@ bool VerifyIceUfragPwdPresent(
RTCError ValidateMids(const cricket::SessionDescription& description) {
std::set<std::string> 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 32 characters.");
"length of 16 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();
}

View File

@ -238,4 +238,30 @@ TEST_F(SdpOfferAnswerTest, BundleCodecCollisionInDifferentBundlesAllowed) {
"WebRTC.PeerConnection.ValidBundledPayloadTypes", false));
}
TEST_F(SdpOfferAnswerTest, LargeMidsAreRejected) {
auto pc = CreatePeerConnection();
std::string sdp =
"v=0\r\n"
"o=- 0 3 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=fingerprint:sha-1 "
"4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n"
"a=setup:actpass\r\n"
"a=ice-ufrag:ETEn\r\n"
"a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n"
"m=video 9 UDP/TLS/RTP/SAVPF 111\r\n"
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp-mux\r\n"
"a=sendonly\r\n"
"a=rtpmap:111 VP8/90000\r\n"
"a=mid:01234567890123456\r\n";
auto desc = CreateSessionDescription(SdpType::kOffer, sdp);
ASSERT_NE(desc, nullptr);
RTCError error;
pc->SetRemoteDescription(std::move(desc), &error);
EXPECT_FALSE(error.ok());
EXPECT_EQ(error.type(), RTCErrorType::INVALID_PARAMETER);
}
} // namespace webrtc