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

Unified Diff: ipc/mojo/ipc_mojo_bootstrap.cc

Issue 892503002: Revert of Revert of IPC::ChannelMojo: Make IPC handling robust against bad messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « ipc/mojo/ipc_mojo_bootstrap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_mojo_bootstrap.cc
diff --git a/ipc/mojo/ipc_mojo_bootstrap.cc b/ipc/mojo/ipc_mojo_bootstrap.cc
index 4af4e503a9d27b04efc732b5c6faf935046693a5..a95dae232a1ce1bf7d5dc8c0de2358c8694bbe19 100644
--- a/ipc/mojo/ipc_mojo_bootstrap.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap.cc
@@ -100,9 +100,14 @@
}
bool MojoServerBootstrap::OnMessageReceived(const Message&) {
- DCHECK_EQ(state(), STATE_WAITING_ACK);
+ if (state() != STATE_WAITING_ACK) {
+ set_state(STATE_ERROR);
+ LOG(ERROR) << "Got inconsistent message from client.";
+ return false;
+ }
+
set_state(STATE_READY);
-
+ CHECK(server_pipe_.is_valid());
delegate()->OnPipeAvailable(
mojo::embedder::ScopedPlatformHandle(server_pipe_.release()));
@@ -129,6 +134,12 @@
}
bool MojoClientBootstrap::OnMessageReceived(const Message& message) {
+ if (state() != STATE_INITIALIZED) {
+ set_state(STATE_ERROR);
+ LOG(ERROR) << "Got inconsistent message from server.";
+ return false;
+ }
+
PlatformFileForTransit pipe;
PickleIterator iter(message);
if (!ParamTraits<PlatformFileForTransit>::Read(&message, &iter, &pipe)) {
« no previous file with comments | « ipc/mojo/ipc_mojo_bootstrap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698