Bug 1408487 - handle parent process returning 0 STUN addrs. r=drno
authorMichael Froman <mfroman@mozilla.com>
Wed, 18 Oct 2017 14:06:02 -0500
changeset 683850 debeb703ceabfb3f084a5a7a5f2b7133a9ae504b
parent 683849 736a76d2816f49c63fa596de38f0b30b893b5ad4
child 683851 544b2dfa1b065fb49ea6f4b84edaa1cc95d5df86
push id85474
push userbmo:emilio@crisal.io
push dateFri, 20 Oct 2017 10:02:12 +0000
reviewersdrno
bugs1408487
milestone58.0a1
Bug 1408487 - handle parent process returning 0 STUN addrs. r=drno 1) don't call StartGathering in e10s mode if parent process failed to provide STUN addrs. 2) set ICE connection state to failed if parent process returns 0 STUN addrs MozReview-Commit-ID: COPr3TavdvM
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -269,16 +269,23 @@ PeerConnectionMedia::StunAddrsHandler::O
 {
   CSFLogInfo(LOGTAG, "%s: receiving (%d) stun addrs", __FUNCTION__,
                                                       (int)addrs.Length());
   if (pcm_) {
     pcm_->mStunAddrs = addrs;
     pcm_->mLocalAddrsCompleted = true;
     pcm_->mStunAddrsRequest = nullptr;
     pcm_->FlushIceCtxOperationQueueIfReady();
+    // If parent process returns 0 STUN addresses, change ICE connection
+    // state to failed.
+    if (!pcm_->mStunAddrs.Length()) {
+      pcm_->SignalIceConnectionStateChange(pcm_->mIceCtxHdlr->ctx().get(),
+                                           NrIceCtx::ICE_CTX_FAILED);
+    }
+
     pcm_ = nullptr;
   }
 }
 
 PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl *parent)
     : mParent(parent),
       mParentHandle(parent->GetHandle()),
       mParentName(parent->GetName()),
@@ -951,16 +958,28 @@ PeerConnectionMedia::EnsureIceGathering_
   if (mProxyServer) {
     mIceCtxHdlr->ctx()->SetProxyServer(*mProxyServer);
   } else if (aProxyOnly) {
     IceGatheringStateChange_s(mIceCtxHdlr->ctx().get(),
                               NrIceCtx::ICE_CTX_GATHER_COMPLETE);
     return;
   }
 
+  // Make sure we don't call NrIceCtx::StartGathering if we're in e10s mode
+  // and we received no STUN addresses from the parent process.  In the
+  // absence of previously provided STUN addresses, StartGathering will
+  // attempt to gather them (as in non-e10s mode), and this will cause a
+  // sandboxing exception in e10s mode.
+  if (!mStunAddrs.Length() && XRE_IsContentProcess()) {
+    CSFLogInfo(LOGTAG,
+               "%s: No STUN addresses returned from parent process",
+               __FUNCTION__);
+    return;
+  }
+
   // Belt and suspenders - in e10s mode, the call below to SetStunAddrs
   // needs to have the proper flags set on ice ctx.  For non-e10s,
   // setting those flags happens in StartGathering.  We could probably
   // just set them here, and only do it here.
   mIceCtxHdlr->ctx()->SetCtxFlags(aDefaultRouteOnly, aProxyOnly);
 
   if (mStunAddrs.Length()) {
     mIceCtxHdlr->ctx()->SetStunAddrs(mStunAddrs);