Bug 1204099: check payload type. r=bwc

MozReview-Commit-ID: 1QEDswjrGuo

--HG--
extra : rebase_source : f77de71a1b8231c5b005abd2b5bba6d28ba71469
This commit is contained in:
Paul Ellenbogen 2016-07-12 11:15:10 -07:00
Родитель 3b07e666f0
Коммит 050f67b249
2 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -37,6 +37,17 @@ MOZ_MTLOG_MODULE("jsep")
MOZ_MTLOG(ML_ERROR, mLastError); \
} while (0);
static std::bitset<128> GetForbiddenSdpPayloadTypes() {
std::bitset<128> forbidden(0);
forbidden[1] = true;
forbidden[2] = true;
forbidden[19] = true;
for (uint16_t i = 64; i < 96; ++i) {
forbidden[i] = true;
}
return forbidden;
}
nsresult
JsepSessionImpl::Init()
{
@ -1658,6 +1669,7 @@ JsepSessionImpl::ParseSdp(const std::string& sdp, UniquePtr<Sdp>* parsedp)
return rv;
}
static const std::bitset<128> forbidden = GetForbiddenSdpPayloadTypes();
if (msection.GetMediaType() == SdpMediaSection::kAudio ||
msection.GetMediaType() == SdpMediaSection::kVideo) {
// Sanity-check that payload type can work with RTP
@ -1668,6 +1680,10 @@ JsepSessionImpl::ParseSdp(const std::string& sdp, UniquePtr<Sdp>* parsedp)
JSEP_SET_ERROR("audio/video payload type is too large: " << fmt);
return NS_ERROR_INVALID_ARG;
}
if (forbidden.test(payloadType)) {
JSEP_SET_ERROR("Illegal audio/video payload type: " << fmt);
return NS_ERROR_INVALID_ARG;
}
}
}
}

Просмотреть файл

@ -2120,6 +2120,21 @@ TEST_P(JsepSessionTest, RenegotiationAnswererDisablesBundleTransport)
answererPairs[0].mRtpTransport.get());
}
TEST_P(JsepSessionTest, ParseRejectsBadMediaFormat)
{
if (GetParam() == "datachannel") {
return;
}
AddTracks(mSessionOff);
std::string offer = CreateOffer();
UniquePtr<Sdp> munge(Parse(offer));
SdpMediaSection& mediaSection = munge->GetMediaSection(0);
mediaSection.AddCodec("75", "DummyFormatVal", 8000, 1);
std::string sdpString = munge->ToString();
nsresult rv = mSessionOff.SetLocalDescription(kJsepSdpOffer, sdpString);
ASSERT_EQ(NS_ERROR_INVALID_ARG, rv);
}
TEST_P(JsepSessionTest, FullCallWithCandidates)
{
AddTracks(mSessionOff);