Bug 1323723: added setup attribute checks. r?bwc
MozReview-Commit-ID: BzlYszgySwW
--- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
@@ -919,16 +919,27 @@ JsepSessionImpl::CreateAnswerMSection(co
mSdpHelper.DisableMsection(sdp, &msection);
return NS_OK;
}
SdpSetupAttribute::Role role;
rv = DetermineAnswererSetupRole(remoteMsection, &role);
NS_ENSURE_SUCCESS(rv, rv);
+ if (mCurrentLocalDescription) {
+ if (mCurrentLocalDescription->GetMediaSectionCount() > mlineIndex) {
+ auto& msection = mCurrentLocalDescription->GetMediaSection(mlineIndex);
+ if (!mSdpHelper.MsectionIsDisabled(msection) &&
+ msection.GetAttributeList().GetSetup().mRole != role) {
+ JSEP_SET_ERROR("Remote side attempted to switch DTLS roles");
+ return NS_ERROR_FAILURE;
+ }
+ }
+ }
+
rv = AddTransportAttributes(&msection, role);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetRecvonlySsrc(&msection);
NS_ENSURE_SUCCESS(rv, rv);
// Only attempt to match up local tracks if the offerer has elected to
// receive traffic.
@@ -1636,21 +1647,25 @@ JsepSessionImpl::ParseSdp(const std::str
const SdpFingerprintAttributeList& fingerprints(
mediaAttrs.GetFingerprint());
if (fingerprints.mFingerprints.empty()) {
JSEP_SET_ERROR("Invalid description, no supported fingerprint algorithms "
"present");
return NS_ERROR_INVALID_ARG;
}
- if (mediaAttrs.HasAttribute(SdpAttribute::kSetupAttribute) &&
- mediaAttrs.GetSetup().mRole == SdpSetupAttribute::kHoldconn) {
- JSEP_SET_ERROR("Description has illegal setup attribute "
- "\"holdconn\" at level "
- << i);
+ if (mediaAttrs.HasAttribute(SdpAttribute::kSetupAttribute)) {
+ if (mediaAttrs.GetSetup().mRole == SdpSetupAttribute::kHoldconn) {
+ JSEP_SET_ERROR("Description has illegal setup attribute "
+ "\"holdconn\" at level "
+ << i);
+ return NS_ERROR_INVALID_ARG;
+ }
+ } else {
+ JSEP_SET_ERROR("Missing setup attribute in m-line " << i);
return NS_ERROR_INVALID_ARG;
}
auto& formats = parsed->GetMediaSection(i).GetFormats();
for (auto f = formats.begin(); f != formats.end(); ++f) {
uint16_t pt;
if (!SdpHelper::GetPtAsInt(*f, &pt)) {
JSEP_SET_ERROR("Payload type \""
@@ -1686,20 +1701,20 @@ JsepSessionImpl::ParseSdp(const std::str
// Sanity-check that payload type can work with RTP
for (const std::string& fmt : msection.GetFormats()) {
uint16_t payloadType;
// TODO (bug 1204099): Make this check for reserved ranges.
if (!SdpHelper::GetPtAsInt(fmt, &payloadType) || payloadType > 127) {
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);
+ if (forbidden.test(payloadType)) {
+ JSEP_SET_ERROR("Illegal audio/video payload type: " << fmt);
return NS_ERROR_INVALID_ARG;
- }
+ }
}
}
}
*parsedp = Move(parsed);
return NS_OK;
}