Bug 1024943 - Check IsContentParent() before use AsContentParent(). r=smaug

This commit is contained in:
"Kan-Ru Chen (陳侃如)" 2014-06-14 15:32:24 +08:00
Родитель 888082a108
Коммит c76743182f
2 изменённых файлов: 36 добавлений и 24 удалений

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

@ -984,11 +984,13 @@ TabParent::RecvSyncMessage(const nsString& aMessage,
{ {
// FIXME Permission check for TabParent in Content process // FIXME Permission check for TabParent in Content process
nsIPrincipal* principal = aPrincipal; nsIPrincipal* principal = aPrincipal;
if (Manager()->IsContentParent()) {
ContentParent* parent = Manager()->AsContentParent(); ContentParent* parent = Manager()->AsContentParent();
if (!ContentParent::IgnoreIPCPrincipal() && if (!ContentParent::IgnoreIPCPrincipal() &&
parent && principal && !AssertAppPrincipal(parent, principal)) { parent && principal && !AssertAppPrincipal(parent, principal)) {
return false; return false;
} }
}
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData); StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows); CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
@ -1004,11 +1006,13 @@ TabParent::AnswerRpcMessage(const nsString& aMessage,
{ {
// FIXME Permission check for TabParent in Content process // FIXME Permission check for TabParent in Content process
nsIPrincipal* principal = aPrincipal; nsIPrincipal* principal = aPrincipal;
if (Manager()->IsContentParent()) {
ContentParent* parent = Manager()->AsContentParent(); ContentParent* parent = Manager()->AsContentParent();
if (!ContentParent::IgnoreIPCPrincipal() && if (!ContentParent::IgnoreIPCPrincipal() &&
parent && principal && !AssertAppPrincipal(parent, principal)) { parent && principal && !AssertAppPrincipal(parent, principal)) {
return false; return false;
} }
}
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData); StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows); CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);
@ -1023,11 +1027,13 @@ TabParent::RecvAsyncMessage(const nsString& aMessage,
{ {
// FIXME Permission check for TabParent in Content process // FIXME Permission check for TabParent in Content process
nsIPrincipal* principal = aPrincipal; nsIPrincipal* principal = aPrincipal;
if (Manager()->IsContentParent()) {
ContentParent* parent = Manager()->AsContentParent(); ContentParent* parent = Manager()->AsContentParent();
if (!ContentParent::IgnoreIPCPrincipal() && if (!ContentParent::IgnoreIPCPrincipal() &&
parent && principal && !AssertAppPrincipal(parent, principal)) { parent && principal && !AssertAppPrincipal(parent, principal)) {
return false; return false;
} }
}
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData); StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForParent(aData);
CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows); CpowIdHolder cpows(Manager()->GetCPOWManager(), aCpows);

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

@ -236,11 +236,13 @@ nsIContentParent::RecvSyncMessage(const nsString& aMsg,
{ {
// FIXME Permission check in Content process // FIXME Permission check in Content process
nsIPrincipal* principal = aPrincipal; nsIPrincipal* principal = aPrincipal;
if (IsContentParent()) {
ContentParent* parent = AsContentParent(); ContentParent* parent = AsContentParent();
if (!ContentParent::IgnoreIPCPrincipal() && if (!ContentParent::IgnoreIPCPrincipal() &&
parent && principal && !AssertAppPrincipal(parent, principal)) { parent && principal && !AssertAppPrincipal(parent, principal)) {
return false; return false;
} }
}
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager; nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) { if (ppm) {
@ -262,11 +264,13 @@ nsIContentParent::AnswerRpcMessage(const nsString& aMsg,
{ {
// FIXME Permission check in Content process // FIXME Permission check in Content process
nsIPrincipal* principal = aPrincipal; nsIPrincipal* principal = aPrincipal;
if (IsContentParent()) {
ContentParent* parent = AsContentParent(); ContentParent* parent = AsContentParent();
if (!ContentParent::IgnoreIPCPrincipal() && if (!ContentParent::IgnoreIPCPrincipal() &&
parent && principal && !AssertAppPrincipal(parent, principal)) { parent && principal && !AssertAppPrincipal(parent, principal)) {
return false; return false;
} }
}
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager; nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) { if (ppm) {
@ -286,11 +290,13 @@ nsIContentParent::RecvAsyncMessage(const nsString& aMsg,
{ {
// FIXME Permission check in Content process // FIXME Permission check in Content process
nsIPrincipal* principal = aPrincipal; nsIPrincipal* principal = aPrincipal;
if (IsContentParent()) {
ContentParent* parent = AsContentParent(); ContentParent* parent = AsContentParent();
if (!ContentParent::IgnoreIPCPrincipal() && if (!ContentParent::IgnoreIPCPrincipal() &&
parent && principal && !AssertAppPrincipal(parent, principal)) { parent && principal && !AssertAppPrincipal(parent, principal)) {
return false; return false;
} }
}
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager; nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) { if (ppm) {