Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit bbfc6ec

Browse files
committed
Bug 1574571. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D43707 --HG-- extra : moz-landing-system : lando
1 parent c987315 commit bbfc6ec

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

ipc/chromium/src/base/shared_memory_win.cc

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,38 @@ bool SharedMemory::CreateInternal(size_t size, bool freezeable) {
111111
DCHECK(mapped_file_ == NULL);
112112
read_only_ = false;
113113

114-
SECURITY_ATTRIBUTES sa;
114+
SECURITY_ATTRIBUTES sa, *psa = nullptr;
115115
SECURITY_DESCRIPTOR sd;
116116
ACL dacl;
117+
nsAutoStringN<sizeof("MozSharedMem_") + 16 * 4> name;
117118

118-
sa.nLength = sizeof(sa);
119-
sa.lpSecurityDescriptor = &sd;
120-
sa.bInheritHandle = FALSE;
121-
122-
if (NS_WARN_IF(!InitializeAcl(&dacl, sizeof(dacl), ACL_REVISION)) ||
123-
NS_WARN_IF(
124-
!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) ||
125-
NS_WARN_IF(!SetSecurityDescriptorDacl(&sd, TRUE, &dacl, FALSE))) {
126-
return false;
127-
}
119+
if (freezeable) {
120+
psa = &sa;
121+
sa.nLength = sizeof(sa);
122+
sa.lpSecurityDescriptor = &sd;
123+
sa.bInheritHandle = FALSE;
124+
125+
if (NS_WARN_IF(!InitializeAcl(&dacl, sizeof(dacl), ACL_REVISION)) ||
126+
NS_WARN_IF(
127+
!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) ||
128+
NS_WARN_IF(!SetSecurityDescriptorDacl(&sd, TRUE, &dacl, FALSE))) {
129+
return false;
130+
}
128131

129-
nsAutoStringN<sizeof("MozSharedMem_") + 16 * 4> name;
130-
if (!mozilla::IsWin8Point1OrLater()) {
131-
name.AssignLiteral("MozSharedMem_");
132-
for (size_t i = 0; i < 4; ++i) {
133-
mozilla::Maybe<uint64_t> randomNum = mozilla::RandomUint64();
134-
if (NS_WARN_IF(randomNum.isNothing())) {
135-
return false;
132+
if (!mozilla::IsWin8Point1OrLater()) {
133+
name.AssignLiteral("MozSharedMem_");
134+
for (size_t i = 0; i < 4; ++i) {
135+
mozilla::Maybe<uint64_t> randomNum = mozilla::RandomUint64();
136+
if (NS_WARN_IF(randomNum.isNothing())) {
137+
return false;
138+
}
139+
name.AppendPrintf("%016llx", *randomNum);
136140
}
137-
name.AppendPrintf("%016llx", *randomNum);
138141
}
139142
}
140143

141-
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE,
142-
0, static_cast<DWORD>(size),
144+
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, psa, PAGE_READWRITE, 0,
145+
static_cast<DWORD>(size),
143146
name.IsEmpty() ? nullptr : name.get());
144147
if (!mapped_file_) return false;
145148

0 commit comments

Comments
 (0)