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

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..7cef6d4da0e12bb1c1c624a8668fb8491c3d7a42 100644
--- a/mojo/edk/system/channel.cc
+++ b/mojo/edk/system/channel.cc
@@ -331,15 +331,23 @@ bool Channel::Message::RewriteHandles(base::ProcessHandle from_process,
DLOG(ERROR) << "Refusing to duplicate invalid handle.";
continue;
}
+ CHECK_NE(handles[i].handle, INVALID_HANDLE_VALUE);
Ken Rockot(use gerrit already) 2016/05/03 16:46:49 Just noticing that this can't be reached given the
DCHECK_EQ(handles[i].owning_process, from_process);
BOOL result = DuplicateHandle(
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