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

Unified Diff: ipc/mojo/ipc_mojo_bootstrap.cc

Issue 725733002: IPC::ChannelMojo: Make IPC handling robust against bad messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | 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..7f19bb43051e741ed686ba7bae80c1ed7e5e6782 100644
--- a/ipc/mojo/ipc_mojo_bootstrap.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap.cc
@@ -100,9 +100,13 @@ void MojoServerBootstrap::OnChannelConnected(int32 peer_pid) {
}
bool MojoServerBootstrap::OnMessageReceived(const Message&) {
- DCHECK_EQ(state(), STATE_WAITING_ACK);
- set_state(STATE_READY);
+ if (state() != STATE_WAITING_ACK) {
viettrungluu 2014/11/13 20:27:57 You should probably document in the header what th
Hajime Morrita 2014/11/13 21:01:18 Done.
+ DLOG(WARNING) << "Got inconsistent message from client.";
viettrungluu 2014/11/13 20:27:57 LOG(ERROR)? This seems pretty serious.
Hajime Morrita 2014/11/13 21:01:18 Done.
+ return false;
+ }
+ set_state(STATE_READY);
+ DCHECK(server_pipe_.is_valid());
viettrungluu 2014/11/13 20:27:57 CHECK?
Hajime Morrita 2014/11/13 21:01:18 Done.
delegate()->OnPipeAvailable(
mojo::embedder::ScopedPlatformHandle(server_pipe_.release()));
@@ -129,6 +133,11 @@ MojoClientBootstrap::MojoClientBootstrap() {
}
bool MojoClientBootstrap::OnMessageReceived(const Message& message) {
+ if (STATE_INITIALIZED != state()) {
viettrungluu 2014/11/13 20:27:57 state() != STATE_INITIALIZED
Hajime Morrita 2014/11/13 21:01:18 Done.
+ DLOG(WARNING) << "Got inconsistent message from server.";
viettrungluu 2014/11/13 20:27:57 LOG(ERROR)?
Hajime Morrita 2014/11/13 21:01:18 Done.
+ return false;
+ }
+
PlatformFileForTransit pipe;
PickleIterator iter(message);
if (!ParamTraits<PlatformFileForTransit>::Read(&message, &iter, &pipe)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698