diff options
author | jiayl@webrtc.org <jiayl@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-04-23 20:46:29 +0000 |
---|---|---|
committer | jiayl@webrtc.org <jiayl@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-04-23 20:46:29 +0000 |
commit | ac12b50104a35b42ff49d847bd4c01782d0434af (patch) | |
tree | e6648e7007cad69e9fafec627ee67b2b96514d77 /p2p | |
parent | 48284e07608ed8f726f67e48879ecc46df48fbd5 (diff) | |
download | talk-ac12b50104a35b42ff49d847bd4c01782d0434af.tar.gz |
Fix the return value of DtlsTransportChannelWrapper::SendPacket in the case of invalid RTP packet.
R=juberti@webrtc.org, mallinath@webrtc.org
BUG=3244
Review URL: https://webrtc-codereview.appspot.com/12299006
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5966 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/base/dtlstransportchannel.cc | 2 | ||||
-rw-r--r-- | p2p/base/dtlstransportchannel_unittest.cc | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/p2p/base/dtlstransportchannel.cc b/p2p/base/dtlstransportchannel.cc index 318ba94..1b3a779 100644 --- a/p2p/base/dtlstransportchannel.cc +++ b/p2p/base/dtlstransportchannel.cc @@ -364,7 +364,7 @@ int DtlsTransportChannelWrapper::SendPacket( if (flags & PF_SRTP_BYPASS) { ASSERT(!srtp_ciphers_.empty()); if (!IsRtpPacket(data, size)) { - result = false; + result = -1; break; } diff --git a/p2p/base/dtlstransportchannel_unittest.cc b/p2p/base/dtlstransportchannel_unittest.cc index cdab332..88f1439 100644 --- a/p2p/base/dtlstransportchannel_unittest.cc +++ b/p2p/base/dtlstransportchannel_unittest.cc @@ -254,6 +254,17 @@ class DtlsTestClient : public sigslot::has_slots<> { } while (sent < count); } + int SendInvalidSrtpPacket(size_t channel, size_t size) { + ASSERT(channel < channels_.size()); + talk_base::scoped_ptr<char[]> packet(new char[size]); + // Fill the packet with 0 to form an invalid SRTP packet. + memset(packet.get(), 0, size); + + talk_base::PacketOptions packet_options; + return channels_[channel]->SendPacket( + packet.get(), size, packet_options, cricket::PF_SRTP_BYPASS); + } + void ExpectPackets(size_t channel, size_t size) { packet_size_ = size; received_.clear(); @@ -624,6 +635,16 @@ TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) { TestTransfer(0, 1000, 100, true); } +// Connect with DTLS-SRTP, transfer an invalid SRTP packet, and expects -1 +// returned. +TEST_F(DtlsTransportChannelTest, TestTransferDtlsInvalidSrtpPacket) { + MAYBE_SKIP_TEST(HaveDtls); + PrepareDtls(true, true); + PrepareDtlsSrtp(true, true); + ASSERT_TRUE(Connect()); + int result = client1_.SendInvalidSrtpPacket(0, 100); + ASSERT_EQ(-1, result); +} // Connect with DTLS. A does DTLS-SRTP but B does not. TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtpRejected) { |