Bug 814222 - Need additional security checks for the networkstats-manage permission. r=philikon

This commit is contained in:
Alberto Crespell Perez 2013-01-07 15:26:41 -08:00
parent 5e42b191c3
commit af053f1ad8
2 changed files with 12 additions and 3 deletions

View File

@ -101,7 +101,7 @@ NetworkStatsManager.prototype = {
checkPrivileges: function checkPrivileges() {
if (!this.hasPrivileges) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
throw Components.Exception("Permission denied", Cr.NS_ERROR_FAILURE);
}
},
@ -198,8 +198,6 @@ NetworkStatsManager.prototype = {
if (!Services.prefs.getBoolPref("dom.mozNetworkStats.enabled")) {
return null;
}
this.initHelper(aWindow, ["NetworkStats:Get:Return",
"NetworkStats:Clear:Return"]);
let principal = aWindow.document.nodePrincipal;
let secMan = Services.scriptSecurityManager;
@ -213,6 +211,13 @@ NetworkStatsManager.prototype = {
if (DEBUG) {
debug("has privileges: " + this.hasPrivileges);
}
if (!this.hasPrivileges) {
return null;
}
this.initHelper(aWindow, ["NetworkStats:Get:Return",
"NetworkStats:Clear:Return"]);
},
// Called from DOMRequestIpcHelper

View File

@ -74,6 +74,10 @@ this.NetworkStatsService = {
},
receiveMessage: function(aMessage) {
if (!aMessage.target.assertPermission("networkstats-manage")) {
return;
}
if (DEBUG) {
debug("receiveMessage " + aMessage.name);
}