diff --git a/call/rtp_demuxer.cc b/call/rtp_demuxer.cc index 841d7e3b94..525acf7b99 100644 --- a/call/rtp_demuxer.cc +++ b/call/rtp_demuxer.cc @@ -40,25 +40,14 @@ size_t RemoveFromMapByValue(Map* map, const Value& value) { return EraseIf(*map, [&](const auto& elem) { return elem.second == value; }); } -// 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. -std::string CheckMidLength(absl::string_view mid) { - std::string new_mid(mid); - if (new_mid.length() > BaseRtpStringExtension::kMaxValueSizeBytes) { - RTC_LOG(LS_WARNING) << "`mid` attribute too long. Truncating."; - new_mid.resize(BaseRtpStringExtension::kMaxValueSizeBytes); - } - return new_mid; -} - } // namespace RtpDemuxerCriteria::RtpDemuxerCriteria( absl::string_view mid, absl::string_view rsid /*= absl::string_view()*/) - : mid_(CheckMidLength(mid)), rsid_(rsid) {} + : mid_(mid), rsid_(rsid) { + RTC_DCHECK(mid.length() <= BaseRtpStringExtension::kMaxValueSizeBytes); +} RtpDemuxerCriteria::RtpDemuxerCriteria() = default; RtpDemuxerCriteria::~RtpDemuxerCriteria() = default; diff --git a/call/rtp_demuxer_unittest.cc b/call/rtp_demuxer_unittest.cc index e85052810a..e460af8536 100644 --- a/call/rtp_demuxer_unittest.cc +++ b/call/rtp_demuxer_unittest.cc @@ -1238,26 +1238,14 @@ TEST_F(RtpDemuxerTest, PacketWithMidAndUnknownRsidIsNotRoutedByPayloadType) { EXPECT_FALSE(demuxer_.OnRtpPacket(*packet)); } -TEST_F(RtpDemuxerTest, MidMustNotExceedMaximumLength) { +#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) + +TEST_F(RtpDemuxerDeathTest, MidMustNotExceedMaximumLength) { MockRtpPacketSink sink1; std::string mid1(BaseRtpStringExtension::kMaxValueSizeBytes + 1, 'a'); - // Adding the sink should pass even though the supplied mid is too long. - // The mid will be truncated though. - EXPECT_TRUE(AddSinkOnlyMid(mid1, &sink1)); - - // Adding a second sink with a mid that matches the truncated mid that was - // just added, should fail. - MockRtpPacketSink sink2; - std::string mid2(mid1.substr(0, BaseRtpStringExtension::kMaxValueSizeBytes)); - EXPECT_FALSE(AddSinkOnlyMid(mid2, &sink2)); - EXPECT_FALSE(RemoveSink(&sink2)); - - // Remove the original sink. - EXPECT_TRUE(RemoveSink(&sink1)); + EXPECT_DEATH(AddSinkOnlyMid(mid1, &sink1), ""); } -#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) - TEST_F(RtpDemuxerDeathTest, CriteriaMustBeNonEmpty) { MockRtpPacketSink sink; RtpDemuxerCriteria criteria;