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

Unified Diff: webrtc/api/webrtcsdp_unittest.cc

Issue 2571073002: Fixing integer overflow when parsing bandwidth attribute. (Closed)
Patch Set: Making code more readable. Created 4 years 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 | « webrtc/api/webrtcsdp.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/webrtcsdp_unittest.cc
diff --git a/webrtc/api/webrtcsdp_unittest.cc b/webrtc/api/webrtcsdp_unittest.cc
index 7941323d973d264cad8b4c92adb573c129e94e4b..c7cb36d9a09d14351cbace6b58c6c10d63075862 100644
--- a/webrtc/api/webrtcsdp_unittest.cc
+++ b/webrtc/api/webrtcsdp_unittest.cc
@@ -3201,3 +3201,22 @@ TEST_F(WebRtcSdpTest, DeserializeSctpPortInVideoDescription) {
ExpectParseFailure(std::string(kSdpWithSctpPortInVideoDescription),
"sctp-port");
}
+
+// Regression test for integer overflow bug:
+// https://bugs.chromium.org/p/chromium/issues/detail?id=648071
+TEST_F(WebRtcSdpTest, DeserializeLargeBandwidthLimit) {
+ JsepSessionDescription jdesc_output(kDummyString);
+
+ // Bandwidth attribute is the max signed 32-bit int, which will get
+ // multiplied by 1000 and cause int overflow if not careful.
+ const char kSdpWithLargeBandwidth[] =
+ "v=0\r\n"
+ "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
+ "s=-\r\n"
+ "t=0 0\r\n"
+ "m=video 3457 RTP/SAVPF 120\r\n"
+ "b=AS:2147483647\r\n"
+ "foo=fail\r\n";
+
+ ExpectParseFailure(std::string(kSdpWithLargeBandwidth), "foo=fail");
+}
« no previous file with comments | « webrtc/api/webrtcsdp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698