Index: base/memory/shared_memory_win.cc |
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc |
index daa700da6a373cd491ce56228f9b58037517c23f..598a50dc7a68f93815f4185b0cbd335f55c5b72a 100644 |
--- a/base/memory/shared_memory_win.cc |
+++ b/base/memory/shared_memory_win.cc |
@@ -13,6 +13,7 @@ |
#include "base/rand_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
+#include "base/unguessable_token.h" |
namespace { |
@@ -240,8 +241,9 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { |
rand_values[2], rand_values[3]); |
} |
DCHECK(!name_.empty()); |
- shm_ = SharedMemoryHandle(CreateFileMappingWithReducedPermissions( |
- &sa, rounded_size, name_.c_str())); |
+ shm_ = SharedMemoryHandle( |
+ CreateFileMappingWithReducedPermissions(&sa, rounded_size, name_.c_str()), |
+ UnguessableToken::Create()); |
if (!shm_.IsValid()) { |
// The error is logged within CreateFileMappingWithReducedPermissions(). |
return false; |
@@ -279,8 +281,13 @@ bool SharedMemory::Open(const std::string& name, bool read_only) { |
access |= FILE_MAP_WRITE; |
name_ = ASCIIToUTF16(name); |
read_only_ = read_only; |
+ |
+ // This form of sharing shared memory is deprecated. https://crbug.com/345734. |
+ // Technically, we should also pass the GUID from the original shared memory |
+ // region. Instead, we should just remove all instances of this. |
Nico
2017/05/05 18:34:36
Likewise?
What's the failure case if someone call
erikchen
2017/05/05 19:29:33
Done.
|
shm_ = SharedMemoryHandle( |
- OpenFileMapping(access, false, name_.empty() ? nullptr : name_.c_str())); |
+ OpenFileMapping(access, false, name_.empty() ? nullptr : name_.c_str()), |
+ UnguessableToken::Create()); |
if (!shm_.IsValid()) |
return false; |
// If a name specified assume it's an external section. |
@@ -332,7 +339,7 @@ SharedMemoryHandle SharedMemory::GetReadOnlyHandle() { |
FILE_MAP_READ | SECTION_QUERY, FALSE, 0)) { |
return SharedMemoryHandle(); |
} |
- SharedMemoryHandle handle = SharedMemoryHandle(result); |
+ SharedMemoryHandle handle = SharedMemoryHandle(result, shm_.GetGUID()); |
handle.SetOwnershipPassesToIPC(true); |
return handle; |
} |