Chromium Code Reviews| Index: ipc/ipc_channel_win.cc |
| diff --git a/ipc/ipc_channel_win.cc b/ipc/ipc_channel_win.cc |
| index 10af1fecdb34a4317c3a4588f9788ba6dbff4f17..11d57c12043530424d8a13164d521b010ee0993f 100644 |
| --- a/ipc/ipc_channel_win.cc |
| +++ b/ipc/ipc_channel_win.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/bind.h" |
| #include "base/compiler_specific.h" |
| #include "base/logging.h" |
| +#include "base/pickle.h" |
| #include "base/process_util.h" |
| #include "base/rand_util.h" |
| #include "base/string_number_conversions.h" |
| @@ -153,17 +154,28 @@ bool Channel::ChannelImpl::WillDispatchInputMessage(Message* msg) { |
| void Channel::ChannelImpl::HandleHelloMessage(const Message& msg) { |
| // The hello message contains one parameter containing the PID. |
| - MessageIterator it = MessageIterator(msg); |
| - int32 claimed_pid = it.NextInt(); |
| - if (validate_client_ && (it.NextInt() != client_secret_)) { |
| + PickleIterator it(msg); |
| + int32 claimed_pid; |
| + if (!it.ReadInt(&claimed_pid)) { |
| NOTREACHED(); |
| - // Something went wrong. Abort connection. |
| Close(); |
| listener()->OnChannelError(); |
| return; |
| } |
| + |
| + if (validate_client_) { |
| + int32 secret; |
| + bool result = it.ReadInt(&secret); |
| + if (!result || secret != client_secret_) { |
| + NOTREACHED(); |
|
jam
2012/12/17 16:21:57
seems unfortunate to duplicate this little block t
|
| + Close(); |
| + listener()->OnChannelError(); |
| + return; |
| + } |
| + } |
| + |
| peer_pid_ = claimed_pid; |
| - // validation completed. |
| + // Validation completed. |
| validate_client_ = false; |
| listener()->OnChannelConnected(claimed_pid); |
| } |