Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: talk/app/webrtc/webrtcsdp_unittest.cc

Issue 1196403004: Prevent JS from bypassing RTP data channel bandwidth limitation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Making sure we only limit bandwidth for RTP (and not SCTP) Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/app/webrtc/webrtcsdp.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/webrtcsdp_unittest.cc
diff --git a/talk/app/webrtc/webrtcsdp_unittest.cc b/talk/app/webrtc/webrtcsdp_unittest.cc
index 2bd6f6d668951d8d16f782142ef55e921ce47ed6..b6577682041c8d305ecd69fb4754706370cf7698 100644
--- a/talk/app/webrtc/webrtcsdp_unittest.cc
+++ b/talk/app/webrtc/webrtcsdp_unittest.cc
@@ -1698,12 +1698,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) {
std::string expected_sdp = kSdpString;
expected_sdp.append(kSdpRtpDataChannelString);
- // We want to test that serializing data content ignores bandwidth
- // settings (it should always be the default). Thus, we don't do
- // the following:
- // TODO(pthatcher): We need to temporarily allow the SDP to control
- // this for backwards-compatibility. Once we don't need that any
- // more, remove this.
+ // Serializing data content shouldn't ignore bandwidth settings.
InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n",
"b=AS:100\r\n",
&expected_sdp);
@@ -2259,28 +2254,39 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndNewPort) {
}
TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) {
- AddRtpDataChannel();
+ // We want to test that deserializing data content limits bandwidth
+ // settings (it should never be greater than the default).
+ // This should prevent someone from using unlimited data bandwidth through
+ // JS and "breaking the Internet".
+ // See: https://code.google.com/p/chromium/issues/detail?id=280726
+ std::string sdp_with_bandwidth = kSdpString;
+ sdp_with_bandwidth.append(kSdpRtpDataChannelString);
+ InjectAfter("a=mid:data_content_name\r\n",
+ "b=AS:100\r\n",
+ &sdp_with_bandwidth);
+ JsepSessionDescription jdesc_with_bandwidth(kDummyString);
+
+ EXPECT_FALSE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
+}
+
+TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) {
+ AddSctpDataChannel();
JsepSessionDescription jdesc(kDummyString);
- // We want to test that deserializing data content ignores bandwidth
- // settings (it should always be the default). Thus, we don't do
- // the following:
- // TODO(pthatcher): We need to temporarily allow the SDP to control
- // this for backwards-compatibility. Once we don't need that any
- // more, remove this.
DataContentDescription* dcd = static_cast<DataContentDescription*>(
GetFirstDataContent(&desc_)->description);
dcd->set_bandwidth(100 * 1000);
ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
std::string sdp_with_bandwidth = kSdpString;
- sdp_with_bandwidth.append(kSdpRtpDataChannelString);
+ sdp_with_bandwidth.append(kSdpSctpDataChannelString);
InjectAfter("a=mid:data_content_name\r\n",
"b=AS:100\r\n",
&sdp_with_bandwidth);
JsepSessionDescription jdesc_with_bandwidth(kDummyString);
- EXPECT_TRUE(
- SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
+ // SCTP has congestion control, so we shouldn't limit the bandwidth
+ // as we do for RTP.
+ EXPECT_TRUE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_with_bandwidth));
}
« no previous file with comments | « talk/app/webrtc/webrtcsdp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698