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 b992d2da909345272eb4de4c84bab955d7ce1a4b..28c124a94db2400c851e6b597885e0a247cafcfd 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_unittest.cc |
@@ -31,6 +31,7 @@ constexpr int32_t kTimeOffset = 0x56ce; |
constexpr bool kVoiceActive = true; |
constexpr uint8_t kAudioLevel = 0x5a; |
constexpr size_t kMaxPaddingSize = 224u; |
+// clang-format off |
constexpr uint8_t kMinimumPacket[] = { |
0x80, kPayloadType, 0x00, kSeqNum, |
0x65, 0x43, 0x12, 0x78, |
@@ -63,7 +64,7 @@ constexpr uint8_t kPacket[] = { |
0x12, 0x00, 0x56, 0xce, |
'p', 'a', 'y', 'l', 'o', 'a', 'd', |
'p', 'a', 'd', 'd', 'i', 'n', 'g', kPacketPaddingSize}; |
- |
+// clang-format on |
} // namespace |
TEST(RtpPacketTest, CreateMinimum) { |
@@ -193,6 +194,36 @@ TEST(RtpPacketTest, ParseWithExtension) { |
EXPECT_EQ(0u, packet.padding_size()); |
} |
+TEST(RtpPacketTest, ParseWithInvalidSizedExtension) { |
+ // clang-format off |
+ constexpr uint8_t kBadPacket[] = { |
+ 0x90, kPayloadType, 0x00, kSeqNum, |
+ 0x65, 0x43, 0x12, 0x78, // kTimestamp. |
+ 0x12, 0x34, 0x56, 0x78, // kSSrc. |
+ 0xbe, 0xde, 0x00, 0x02, // Extension block of size 2 x 32bit words. |
+ (kTransmissionOffsetExtensionId << 4) | 6, // (6+1)-byte extension, but |
+ 'e', 'x', 't', // Transmission Offset |
+ 'd', 'a', 't', 'a', // expected to be 3-bytes. |
+ 'p', 'a', 'y', 'l', 'o', 'a', 'd', |
+ }; |
+ // clang-format on |
+ |
+ RtpPacketToSend::ExtensionManager extensions; |
+ extensions.Register(kRtpExtensionTransmissionTimeOffset, |
+ kTransmissionOffsetExtensionId); |
+ |
+ RtpPacketReceived packet(&extensions); |
+ EXPECT_TRUE(packet.Parse(kBadPacket, sizeof(kBadPacket))); |
+ |
+ // Extension should be ignored. |
+ int32_t time_offset; |
+ EXPECT_FALSE(packet.GetExtension<TransmissionOffset>(&time_offset)); |
+ |
+ // But shouldn't prevent reading payload. |
+ EXPECT_THAT(make_tuple(packet.payload(), packet.payload_size()), |
+ ElementsAreArray(kPayload)); |
+} |
+ |
TEST(RtpPacketTest, ParseWith2Extensions) { |
RtpPacketToSend::ExtensionManager extensions; |
extensions.Register(kRtpExtensionTransmissionTimeOffset, |