Bug 1010434 - NeckoParent matches a wrong app for the request of a new RemoteOpenFile. r=bent

This commit is contained in:
Jason Duell 2014-05-30 12:50:51 -07:00
parent 03ace1f91a
commit a53a63d71e
8 changed files with 50 additions and 29 deletions

View File

@ -375,8 +375,11 @@ nsJARChannel::LookupFile()
// Open file on parent: OnRemoteFileOpenComplete called when done
nsCOMPtr<nsITabChild> tabChild;
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, tabChild);
rv = remoteFile->AsyncRemoteFileOpen(PR_RDONLY, this, tabChild.get());
NS_QueryNotificationCallbacks(this, tabChild);
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(this, loadContext);
rv = remoteFile->AsyncRemoteFileOpen(PR_RDONLY, this, tabChild,
loadContext);
NS_ENSURE_SUCCESS(rv, rv);
}
}

View File

@ -269,7 +269,9 @@ NeckoChild::DeallocPDNSRequestChild(PDNSRequestChild* aChild)
}
PRemoteOpenFileChild*
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&, const OptionalURIParams&)
NeckoChild::AllocPRemoteOpenFileChild(const SerializedLoadContext& aSerialized,
const URIParams&,
const OptionalURIParams&)
{
// We don't allocate here: instead we always use IPDL constructor that takes
// an existing RemoteOpenFileChild

View File

@ -57,7 +57,8 @@ protected:
const uint32_t& aFlags) MOZ_OVERRIDE;
virtual bool DeallocPDNSRequestChild(PDNSRequestChild*) MOZ_OVERRIDE;
virtual PRemoteOpenFileChild*
AllocPRemoteOpenFileChild(const URIParams&,
AllocPRemoteOpenFileChild(const SerializedLoadContext& aSerialized,
const URIParams&,
const OptionalURIParams&) MOZ_OVERRIDE;
virtual bool DeallocPRemoteOpenFileChild(PRemoteOpenFileChild*) MOZ_OVERRIDE;
virtual PRtspControllerChild* AllocPRtspControllerChild() MOZ_OVERRIDE;

View File

@ -500,7 +500,8 @@ NeckoParent::DeallocPDNSRequestParent(PDNSRequestParent* aParent)
}
PRemoteOpenFileParent*
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
NeckoParent::AllocPRemoteOpenFileParent(const SerializedLoadContext& aSerialized,
const URIParams& aURI,
const OptionalURIParams& aAppURI)
{
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
@ -523,17 +524,21 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
nsRefPtr<TabParent> tabParent =
static_cast<TabParent*>(Manager()->ManagedPBrowserParent()[i]);
uint32_t appId = tabParent->OwnOrContainingAppId();
nsresult rv = appsService->GetAppByLocalId(appId, getter_AddRefs(mozApp));
if (NS_FAILED(rv) || !mozApp) {
continue;
// Note: this enforces that SerializedLoadContext.appID is one of the apps
// in the child process, but there's currently no way to verify the
// request is not from a different app in that process.
if (appId == aSerialized.mAppId) {
nsresult rv = appsService->GetAppByLocalId(appId, getter_AddRefs(mozApp));
if (NS_FAILED(rv) || !mozApp) {
break;
}
rv = mozApp->HasPermission("webapps-manage", &hasManage);
if (NS_FAILED(rv)) {
break;
}
haveValidBrowser = true;
break;
}
hasManage = false;
rv = mozApp->HasPermission("webapps-manage", &hasManage);
if (NS_FAILED(rv)) {
continue;
}
haveValidBrowser = true;
break;
}
if (!haveValidBrowser) {
@ -621,9 +626,11 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
}
bool
NeckoParent::RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
const URIParams& aFileURI,
const OptionalURIParams& aAppURI)
NeckoParent::RecvPRemoteOpenFileConstructor(
PRemoteOpenFileParent* aActor,
const SerializedLoadContext& aSerialized,
const URIParams& aFileURI,
const OptionalURIParams& aAppURI)
{
return static_cast<RemoteOpenFileParent*>(aActor)->OpenSendCloseDelete();
}

View File

@ -100,13 +100,16 @@ protected:
virtual bool DeallocPWebSocketParent(PWebSocketParent*) MOZ_OVERRIDE;
virtual PTCPSocketParent* AllocPTCPSocketParent() MOZ_OVERRIDE;
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI,
const OptionalURIParams& aAppURI)
MOZ_OVERRIDE;
virtual bool RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
const URIParams& aFileURI,
const OptionalURIParams& aAppURI)
MOZ_OVERRIDE;
virtual PRemoteOpenFileParent*
AllocPRemoteOpenFileParent(const SerializedLoadContext& aSerialized,
const URIParams& aFileURI,
const OptionalURIParams& aAppURI) MOZ_OVERRIDE;
virtual bool
RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
const SerializedLoadContext& aSerialized,
const URIParams& aFileURI,
const OptionalURIParams& aAppURI)
MOZ_OVERRIDE;
virtual bool DeallocPRemoteOpenFileParent(PRemoteOpenFileParent* aActor)
MOZ_OVERRIDE;

View File

@ -68,7 +68,9 @@ parent:
PDNSRequest(nsCString hostName, uint32_t flags);
PRemoteOpenFile(URIParams fileuri, OptionalURIParams appuri);
PRemoteOpenFile(SerializedLoadContext loadContext,
URIParams fileuri,
OptionalURIParams appuri);
HTMLDNSPrefetch(nsString hostname, uint16_t flags);
CancelHTMLDNSPrefetch(nsString hostname, uint16_t flags, nsresult reason);

View File

@ -175,7 +175,8 @@ RemoteOpenFileChild::Init(nsIURI* aRemoteOpenUri, nsIURI* aAppUri)
nsresult
RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
nsIRemoteOpenFileListener* aListener,
nsITabChild* aTabChild)
nsITabChild* aTabChild,
nsILoadContext *aLoadContext)
{
if (!mFile) {
return NS_ERROR_NOT_INITIALIZED;
@ -227,7 +228,8 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
OptionalURIParams appUri;
SerializeURI(mAppURI, appUri);
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri, appUri);
IPC::SerializedLoadContext loadContext(aLoadContext);
gNeckoChild->SendPRemoteOpenFileConstructor(this, loadContext, uri, appUri);
// The chrome process now has a logical ref to us until it calls Send__delete.
AddIPDLReference();

View File

@ -72,7 +72,8 @@ public:
// Note: currently only PR_RDONLY is supported for 'flags'
nsresult AsyncRemoteFileOpen(int32_t aFlags,
nsIRemoteOpenFileListener* aListener,
nsITabChild* aTabChild);
nsITabChild* aTabChild,
nsILoadContext *aLoadContext);
void ReleaseIPDLReference()
{