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

Side by Side Diff: mojo/edk/system/node_controller.cc

Issue 1987593002: [mojo-edk] Sanity checks on ports message parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/system/node_controller.h" 5 #include "mojo/edk/system/node_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 while (!message_queue.empty()) { 783 while (!message_queue.empty()) {
784 broker->RelayPortsMessage(destination, std::move(message_queue.front())); 784 broker->RelayPortsMessage(destination, std::move(message_queue.front()));
785 message_queue.pop(); 785 message_queue.pop();
786 } 786 }
787 } 787 }
788 #endif 788 #endif
789 789
790 DVLOG(1) << "Child " << name_ << " accepted by broker " << broker_name; 790 DVLOG(1) << "Child " << name_ << " accepted by broker " << broker_name;
791 } 791 }
792 792
793 void NodeController::OnPortsMessage(Channel::MessagePtr channel_message) { 793 void NodeController::OnPortsMessage(const ports::NodeName& from_node,
794 Channel::MessagePtr channel_message) {
794 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 795 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
795 796
796 void* data; 797 void* data;
797 size_t num_data_bytes; 798 size_t num_data_bytes;
798 NodeChannel::GetPortsMessageData( 799 NodeChannel::GetPortsMessageData(
799 channel_message.get(), &data, &num_data_bytes); 800 channel_message.get(), &data, &num_data_bytes);
801 if (!num_data_bytes) {
802 DropPeer(from_node);
803 return;
804 }
800 805
801 size_t num_header_bytes, num_payload_bytes, num_ports_bytes; 806 size_t num_header_bytes, num_payload_bytes, num_ports_bytes;
802 ports::Message::Parse(data, 807 if (!ports::Message::Parse(data,
803 num_data_bytes, 808 num_data_bytes,
804 &num_header_bytes, 809 &num_header_bytes,
805 &num_payload_bytes, 810 &num_payload_bytes,
806 &num_ports_bytes); 811 &num_ports_bytes)) {
812 DropPeer(from_node);
813 return;
814 }
807 815
808 CHECK(channel_message); 816 CHECK(channel_message);
809 ports::ScopedMessage message( 817 ports::ScopedMessage message(
810 new PortsMessage(num_header_bytes, 818 new PortsMessage(num_header_bytes,
811 num_payload_bytes, 819 num_payload_bytes,
812 num_ports_bytes, 820 num_ports_bytes,
813 std::move(channel_message))); 821 std::move(channel_message)));
814 822
815 node_->AcceptMessage(std::move(message)); 823 node_->AcceptMessage(std::move(message));
816 AcceptIncomingMessages(); 824 AcceptIncomingMessages();
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 shutdown_callback_flag_.Set(false); 1006 shutdown_callback_flag_.Set(false);
999 } 1007 }
1000 1008
1001 DCHECK(!callback.is_null()); 1009 DCHECK(!callback.is_null());
1002 1010
1003 callback.Run(); 1011 callback.Run();
1004 } 1012 }
1005 1013
1006 } // namespace edk 1014 } // namespace edk
1007 } // namespace mojo 1015 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698