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

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

Issue 1940353002: [mojo-edk] Invalidate message handle when rewrite fails (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/embedder/platform_handle_utils_win.cc ('k') | mojo/edk/system/node_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel.cc
diff --git a/mojo/edk/system/channel.cc b/mojo/edk/system/channel.cc
index a03668ba1af72f281f72889555ddc4a104c8f35c..c8d693176c917620207a73335d47f7634eb1aab3 100644
--- a/mojo/edk/system/channel.cc
+++ b/mojo/edk/system/channel.cc
@@ -336,10 +336,17 @@ bool Channel::Message::RewriteHandles(base::ProcessHandle from_process,
from_process, handles[i].handle, to_process,
&handles[i].handle, 0, FALSE,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
- if (result)
+ if (result) {
handles[i].owning_process = to_process;
- else
+ } else {
success = false;
+
+ // If handle duplication fails, the source handle will already be closed
+ // due to DUPLICATE_CLOSE_SOURCE. Replace the handle in the message with
+ // an invalid handle.
+ handles[i].handle = INVALID_HANDLE_VALUE;
+ handles[i].owning_process = base::GetCurrentProcessHandle();
+ }
}
return success;
}
« no previous file with comments | « mojo/edk/embedder/platform_handle_utils_win.cc ('k') | mojo/edk/system/node_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698