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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc

Issue 2327743003: Fix oversized rtp header extension parsing. (Closed)
Patch Set: Fix + nits nearby Created 4 years, 3 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 | « webrtc/modules/rtp_rtcp/source/rtp_packet.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
index 63a171dfb3c8d9d4878feea0d2498fcb9d4279e4..010d57bae7543f27af650adcd32d95577ebeb71f 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc
@@ -223,6 +223,29 @@ TEST(RtpPacketTest, ParseWithInvalidSizedExtension) {
ElementsAreArray(kPayload));
}
+TEST(RtpPacketTest, ParseWithOverSizedExtension) {
+ // clang-format off
+ const uint8_t bad_packet[] = {
+ 0x90, kPayloadType, 0x00, kSeqNum,
+ 0x65, 0x43, 0x12, 0x78, // kTimestamp.
+ 0x12, 0x34, 0x56, 0x78, // kSsrc.
+ 0xbe, 0xde, 0x00, 0x01, // Extension of size 1x32bit word.
+ 0x00, // Add a byte of padding.
+ 0x12, // Extension id 1 size (2+1).
+ 0xda, 0x1a // Only 2 bytes of extension payload.
+ };
+ // clang-format on
+ RtpPacketToSend::ExtensionManager extensions;
+ extensions.Register(TransmissionOffset::kId, 1);
+ RtpPacketReceived packet(&extensions);
+
+ // Parse should ignore bad extension and proceed.
+ EXPECT_TRUE(packet.Parse(bad_packet, sizeof(bad_packet)));
+ int32_t time_offset;
+ // But extracting extension should fail.
+ EXPECT_FALSE(packet.GetExtension<TransmissionOffset>(&time_offset));
+}
+
TEST(RtpPacketTest, ParseWith2Extensions) {
RtpPacketToSend::ExtensionManager extensions;
extensions.Register(kRtpExtensionTransmissionTimeOffset,
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698