зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avoid multiple subsequent lookups in security/sandbox/linux/broker. r=jld
Differential Revision: https://phabricator.services.mozilla.com/D106116
This commit is contained in:
Родитель
b33a0c377a
Коммит
eefee48405
|
@ -147,23 +147,19 @@ void SandboxBroker::Policy::AddPath(int aPerms, const char* aPath,
|
||||||
AddCondition aCond) {
|
AddCondition aCond) {
|
||||||
nsDependentCString path(aPath);
|
nsDependentCString path(aPath);
|
||||||
MOZ_ASSERT(path.Length() <= kMaxPathLen);
|
MOZ_ASSERT(path.Length() <= kMaxPathLen);
|
||||||
int perms;
|
|
||||||
if (aCond == AddIfExistsNow) {
|
if (aCond == AddIfExistsNow) {
|
||||||
struct stat statBuf;
|
struct stat statBuf;
|
||||||
if (lstat(aPath, &statBuf) != 0) {
|
if (lstat(aPath, &statBuf) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mMap.Get(path, &perms)) {
|
auto& perms = mMap.LookupOrInsert(path, MAY_ACCESS);
|
||||||
perms = MAY_ACCESS;
|
MOZ_ASSERT(perms & MAY_ACCESS);
|
||||||
} else {
|
|
||||||
MOZ_ASSERT(perms & MAY_ACCESS);
|
|
||||||
}
|
|
||||||
if (SandboxInfo::Get().Test(SandboxInfo::kVerbose)) {
|
if (SandboxInfo::Get().Test(SandboxInfo::kVerbose)) {
|
||||||
SANDBOX_LOG_ERROR("policy for %s: %d -> %d", aPath, perms, perms | aPerms);
|
SANDBOX_LOG_ERROR("policy for %s: %d -> %d", aPath, perms, perms | aPerms);
|
||||||
}
|
}
|
||||||
perms |= aPerms;
|
perms |= aPerms;
|
||||||
mMap.InsertOrUpdate(path, perms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SandboxBroker::Policy::AddTree(int aPerms, const char* aPath) {
|
void SandboxBroker::Policy::AddTree(int aPerms, const char* aPath) {
|
||||||
|
@ -229,18 +225,15 @@ void SandboxBroker::Policy::AddPrefix(int aPerms, const char* aPath) {
|
||||||
|
|
||||||
void SandboxBroker::Policy::AddPrefixInternal(int aPerms,
|
void SandboxBroker::Policy::AddPrefixInternal(int aPerms,
|
||||||
const nsACString& aPath) {
|
const nsACString& aPath) {
|
||||||
int origPerms;
|
auto& perms = mMap.LookupOrInsert(aPath, MAY_ACCESS);
|
||||||
if (!mMap.Get(aPath, &origPerms)) {
|
MOZ_ASSERT(perms & MAY_ACCESS);
|
||||||
origPerms = MAY_ACCESS;
|
|
||||||
} else {
|
int newPerms = perms | aPerms | RECURSIVE;
|
||||||
MOZ_ASSERT(origPerms & MAY_ACCESS);
|
|
||||||
}
|
|
||||||
int newPerms = origPerms | aPerms | RECURSIVE;
|
|
||||||
if (SandboxInfo::Get().Test(SandboxInfo::kVerbose)) {
|
if (SandboxInfo::Get().Test(SandboxInfo::kVerbose)) {
|
||||||
SANDBOX_LOG_ERROR("policy for %s: %d -> %d",
|
SANDBOX_LOG_ERROR("policy for %s: %d -> %d",
|
||||||
PromiseFlatCString(aPath).get(), origPerms, newPerms);
|
PromiseFlatCString(aPath).get(), perms, newPerms);
|
||||||
}
|
}
|
||||||
mMap.InsertOrUpdate(aPath, newPerms);
|
perms = newPerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SandboxBroker::Policy::AddFilePrefix(int aPerms, const char* aDir,
|
void SandboxBroker::Policy::AddFilePrefix(int aPerms, const char* aDir,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче