Index: base/memory/shared_memory_win.cc |
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc |
index cc177ab3f2155625965c117b00947282d566af6d..1aab431fbe841c05e754b46e14457952d81d3e72 100644 |
--- a/base/memory/shared_memory_win.cc |
+++ b/base/memory/shared_memory_win.cc |
@@ -5,6 +5,8 @@ |
#include "base/memory/shared_memory.h" |
#include "base/logging.h" |
+#include "base/rand_util.h" |
+#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
namespace { |
@@ -114,10 +116,18 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { |
size_t rounded_size = (options.size + kSectionMask) & ~kSectionMask; |
name_ = ASCIIToWide(options.name_deprecated == NULL ? "" : |
- *options.name_deprecated); |
+ *options.name_deprecated); |
+ if (name_.empty()) { |
+ // Windows ignores DACLs on certain named objects (like shared sections). |
+ // So, we generate a random one in case we need the DACL enforced. |
+ uint64_t rand_values[4]; |
+ base::RandBytes(&rand_values, sizeof(rand_values)); |
+ name_ = base::StringPrintf(L"CrSharedMem_%016x%016x%016x%016x", |
+ rand_values[0], rand_values[1], |
+ rand_values[2], rand_values[3]); |
+ } |
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, |
- PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size), |
- name_.empty() ? NULL : name_.c_str()); |
+ PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size), name_.c_str()); |
cpu_(ooo_6.6-7.5)
2014/07/23 22:11:43
lgtm
You are changing the name_ member, won't tha
jschuh
2014/07/23 22:19:39
There's no method to retrieve the name, so it shou
|
if (!mapped_file_) |
return false; |