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@5966 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
jiayl@webrtc.org 2014-04-23 20:46:29 +00:00
parent e9d3760d5c
commit 0d915ff603
2 changed files with 22 additions and 1 deletions

View File

@ -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;
}

View File

@ -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) {