Bug 835868 - Consolidate cross-process permission checks for TCPSocket. r=jdm

This commit is contained in:
Glenna Buford 2013-02-26 13:57:39 -05:00
parent e34d7b5105
commit 10cd22acc0
3 changed files with 9 additions and 11 deletions

View File

@ -44,15 +44,8 @@ NS_INTERFACE_MAP_END
bool
TCPSocketParent::Init(const nsString& aHost, const uint16_t& aPort, const bool& aUseSSL,
const nsString& aBinaryType, PBrowserParent* aBrowser)
const nsString& aBinaryType)
{
// We don't have browser actors in xpcshell, and hence can't run automated
// tests without this loophole.
if (aBrowser && !AssertAppProcessPermission(aBrowser, "tcp-socket")) {
FireInteralError(this, __LINE__);
return true;
}
nsresult rv;
mIntermediary = do_CreateInstance("@mozilla.org/tcp-socket-intermediary;1", &rv);
if (NS_FAILED(rv)) {

View File

@ -27,8 +27,7 @@ public:
TCPSocketParent() : mIntermediaryObj(nullptr), mIPCOpen(true) {}
bool Init(const nsString& aHost, const uint16_t& aPort,
const bool& useSSL, const nsString& aBinaryType,
PBrowserParent* aBrowser);
const bool& useSSL, const nsString& aBinaryType);
virtual bool RecvSuspend() MOZ_OVERRIDE;
virtual bool RecvResume() MOZ_OVERRIDE;

View File

@ -17,6 +17,7 @@
#include "mozilla/dom/network/TCPSocketParent.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/LoadContext.h"
#include "mozilla/AppProcessChecker.h"
#include "nsPrintfCString.h"
#include "nsHTMLDNSPrefetch.h"
#include "nsIAppsService.h"
@ -274,6 +275,11 @@ NeckoParent::AllocPTCPSocket(const nsString& aHost,
KILLING CHILD PROCESS\n");
return nullptr;
}
if (aBrowser && !AssertAppProcessPermission(aBrowser, "tcp-socket")) {
printf_stderr("NeckoParent::AllocPTCPSocket: FATAL error: app doesn't permit tcp-socket connections \
KILLING CHILD PROCESS\n");
return nullptr;
}
TCPSocketParent* p = new TCPSocketParent();
p->AddRef();
return p;
@ -288,7 +294,7 @@ NeckoParent::RecvPTCPSocketConstructor(PTCPSocketParent* aActor,
PBrowserParent* aBrowser)
{
return static_cast<TCPSocketParent*>(aActor)->
Init(aHost, aPort, useSSL, aBinaryType, aBrowser);
Init(aHost, aPort, useSSL, aBinaryType);
}
bool