Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: base/memory/shared_memory_win.cc

Issue 1372153002: Detecting and fixing stringprintf.h format bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate #if defined blocks. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/files/file_path.h ('k') | base/strings/stringprintf.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return false; 139 return false;
140 if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) 140 if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
141 return false; 141 return false;
142 if (!SetSecurityDescriptorDacl(&sd, TRUE, &dacl, FALSE)) 142 if (!SetSecurityDescriptorDacl(&sd, TRUE, &dacl, FALSE))
143 return false; 143 return false;
144 144
145 // Windows ignores DACLs on certain unnamed objects (like shared sections). 145 // Windows ignores DACLs on certain unnamed objects (like shared sections).
146 // So, we generate a random name when we need to enforce read-only. 146 // So, we generate a random name when we need to enforce read-only.
147 uint64_t rand_values[4]; 147 uint64_t rand_values[4];
148 RandBytes(&rand_values, sizeof(rand_values)); 148 RandBytes(&rand_values, sizeof(rand_values));
149 name_ = StringPrintf(L"CrSharedMem_%016x%016x%016x%016x", 149 name_ = StringPrintf(L"CrSharedMem_%016llx%016llx%016llx%016llx",
150 rand_values[0], rand_values[1], 150 rand_values[0], rand_values[1],
151 rand_values[2], rand_values[3]); 151 rand_values[2], rand_values[3]);
152 } 152 }
153 mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, 153 mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, &sa,
154 PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size), 154 PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size),
155 name_.empty() ? nullptr : name_.c_str()); 155 name_.empty() ? nullptr : name_.c_str());
156 if (!mapped_file_) 156 if (!mapped_file_)
157 return false; 157 return false;
158 158
159 requested_size_ = options.size; 159 requested_size_ = options.size;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 ::CloseHandle(mapped_file_); 263 ::CloseHandle(mapped_file_);
264 mapped_file_ = NULL; 264 mapped_file_ = NULL;
265 } 265 }
266 } 266 }
267 267
268 SharedMemoryHandle SharedMemory::handle() const { 268 SharedMemoryHandle SharedMemory::handle() const {
269 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); 269 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId());
270 } 270 }
271 271
272 } // namespace base 272 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_path.h ('k') | base/strings/stringprintf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698