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

Unified Diff: mojo/edk/system/node_channel.cc

Issue 1914053003: [mojo-edk] Fix lifetime management of rewritten Windows HANDLEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/channel.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/node_channel.cc
diff --git a/mojo/edk/system/node_channel.cc b/mojo/edk/system/node_channel.cc
index 1be5e47cec7cde85f60ae0db2f07439683a6d8c8..a50e1c6ce2badba471d2885e7ab3457f9a3e1686 100644
--- a/mojo/edk/system/node_channel.cc
+++ b/mojo/edk/system/node_channel.cc
@@ -394,11 +394,20 @@ void NodeChannel::OnChannelMessage(const void* payload,
{
base::AutoLock lock(remote_process_handle_lock_);
if (handles && remote_process_handle_ != base::kNullProcessHandle) {
+ // Note that we explicitly mark the handles as being owned by the sending
+ // process before rewriting them, in order to accommodate RewriteHandles'
+ // internal sanity checks.
+ for (auto& handle : *handles)
+ handle.owning_process = remote_process_handle_;
if (!Channel::Message::RewriteHandles(remote_process_handle_,
base::GetCurrentProcessHandle(),
handles->data(), handles->size())) {
DLOG(ERROR) << "Received one or more invalid handles.";
}
+ } else if (handles) {
+ // Handles received by an unknown process must already be owned by us.
+ for (auto& handle : *handles)
+ handle.owning_process = base::GetCurrentProcessHandle();
}
}
#elif defined(OS_MACOSX) && !defined(OS_IOS)
« no previous file with comments | « mojo/edk/system/channel.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698