From cd467b51aba4188995eaa9c48e00f482d6ffcea4 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Fri, 29 Jan 2021 09:29:47 +0100 Subject: [PATCH] sdp: check that sctp is on a application content type regression from https://webrtc-review.googlesource.com/c/src/+/197813 which attempted to cast the unsupported content type with a sctp protocol to a application/datachannel one. BUG=chromium:1171965 Change-Id: I87c63da83b9f49d968e9b045bb1079f687ab226e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/204481 Reviewed-by: Harald Alvestrand Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/master@{#33100} --- pc/webrtc_sdp.cc | 3 ++- pc/webrtc_sdp_unittest.cc | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index 9544a87803..220e75261b 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -3129,7 +3129,8 @@ bool ParseContent(const std::string& message, if (!ParseDtlsSetup(line, &(transport->connection_role), error)) { return false; } - } else if (cricket::IsDtlsSctp(protocol)) { + } else if (cricket::IsDtlsSctp(protocol) && + media_type == cricket::MEDIA_TYPE_DATA) { // // SCTP specific attributes // diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index 44655fd166..296781f202 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -4760,3 +4760,18 @@ TEST_F(WebRtcSdpTest, MediaTypeProtocolMismatch) { ExpectParseFailure(std::string(sdp + "m=application 9 SOMETHING 120\r\n"), "m=application"); } + +// Regression test for: +// https://bugs.chromium.org/p/chromium/issues/detail?id=1171965 +TEST_F(WebRtcSdpTest, SctpPortInUnsupportedContent) { + std::string sdp = + "v=0\r\n" + "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "m=o 1 DTLS/SCTP 5000\r\n" + "a=sctp-port\r\n"; + + JsepSessionDescription jdesc_output(kDummyType); + EXPECT_TRUE(SdpDeserialize(sdp, &jdesc_output)); +}