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

Side by Side Diff: remoting/host/daemon_process.cc

Issue 12390027: Crash the network or desktop process when an unknown IPC message is received. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/host/desktop_process.cc » ('j') | remoting/host/desktop_process.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/daemon_process.h" 5 #include "remoting/host/daemon_process.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 58 DCHECK(caller_task_runner()->BelongsToCurrentThread());
59 59
60 bool handled = true; 60 bool handled = true;
61 IPC_BEGIN_MESSAGE_MAP(DaemonProcess, message) 61 IPC_BEGIN_MESSAGE_MAP(DaemonProcess, message)
62 IPC_MESSAGE_HANDLER(ChromotingNetworkHostMsg_ConnectTerminal, 62 IPC_MESSAGE_HANDLER(ChromotingNetworkHostMsg_ConnectTerminal,
63 CreateDesktopSession) 63 CreateDesktopSession)
64 IPC_MESSAGE_HANDLER(ChromotingNetworkHostMsg_DisconnectTerminal, 64 IPC_MESSAGE_HANDLER(ChromotingNetworkHostMsg_DisconnectTerminal,
65 CloseDesktopSession) 65 CloseDesktopSession)
66 IPC_MESSAGE_UNHANDLED(handled = false) 66 IPC_MESSAGE_UNHANDLED(handled = false)
67 IPC_END_MESSAGE_MAP() 67 IPC_END_MESSAGE_MAP()
68
69 if (!handled) {
70 LOG(ERROR) << "An unexpected IPC message received: type=" << message.type();
71 CrashNetworkProcess(FROM_HERE);
72 }
73
68 return handled; 74 return handled;
Wez 2013/03/04 23:17:09 Do you know what IpcChannel itself does with the |
alexeypa (please no reviews) 2013/03/05 00:01:44 It ignores the returned value.
69 } 75 }
70 76
71 void DaemonProcess::OnPermanentError() { 77 void DaemonProcess::OnPermanentError() {
72 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 78 DCHECK(caller_task_runner()->BelongsToCurrentThread());
73 Stop(); 79 Stop();
74 } 80 }
75 81
76 void DaemonProcess::CloseDesktopSession(int terminal_id) { 82 void DaemonProcess::CloseDesktopSession(int terminal_id) {
77 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 83 DCHECK(caller_task_runner()->BelongsToCurrentThread());
78 84
79 // Validate the supplied terminal ID. An attempt to close a desktop session 85 // Validate the supplied terminal ID. An attempt to close a desktop session
80 // with an ID that couldn't possibly have been allocated is considered 86 // with an ID that couldn't possibly have been allocated is considered
81 // a protocol error and the network process will be restarted. 87 // a protocol error and the network process will be restarted.
82 if (!IsTerminalIdKnown(terminal_id)) { 88 if (!IsTerminalIdKnown(terminal_id)) {
83 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; 89 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id;
84 CrashNetworkProcess(FROM_HERE); 90 CrashNetworkProcess(FROM_HERE);
85 DeleteAllDesktopSessions();
86 return; 91 return;
87 } 92 }
88 93
89 DesktopSessionList::iterator i; 94 DesktopSessionList::iterator i;
90 for (i = desktop_sessions_.begin(); i != desktop_sessions_.end(); ++i) { 95 for (i = desktop_sessions_.begin(); i != desktop_sessions_.end(); ++i) {
91 if ((*i)->id() == terminal_id) { 96 if ((*i)->id() == terminal_id) {
92 break; 97 break;
93 } 98 }
94 } 99 }
95 100
(...skipping 28 matching lines...) Expand all
124 129
125 void DaemonProcess::CreateDesktopSession(int terminal_id) { 130 void DaemonProcess::CreateDesktopSession(int terminal_id) {
126 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 131 DCHECK(caller_task_runner()->BelongsToCurrentThread());
127 132
128 // Validate the supplied terminal ID. An attempt to create a desktop session 133 // Validate the supplied terminal ID. An attempt to create a desktop session
129 // with an ID that could possibly have been allocated already is considered 134 // with an ID that could possibly have been allocated already is considered
130 // a protocol error and the network process will be restarted. 135 // a protocol error and the network process will be restarted.
131 if (IsTerminalIdKnown(terminal_id)) { 136 if (IsTerminalIdKnown(terminal_id)) {
132 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; 137 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id;
133 CrashNetworkProcess(FROM_HERE); 138 CrashNetworkProcess(FROM_HERE);
134 DeleteAllDesktopSessions();
135 return; 139 return;
136 } 140 }
137 141
138 VLOG(1) << "Daemon: opened desktop session " << terminal_id; 142 VLOG(1) << "Daemon: opened desktop session " << terminal_id;
139 desktop_sessions_.push_back( 143 desktop_sessions_.push_back(
140 DoCreateDesktopSession(terminal_id).release()); 144 DoCreateDesktopSession(terminal_id).release());
141 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); 145 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1);
142 } 146 }
143 147
144 void DaemonProcess::CrashNetworkProcess( 148 void DaemonProcess::CrashNetworkProcess(
145 const tracked_objects::Location& location) { 149 const tracked_objects::Location& location) {
146 SendToNetwork(new ChromotingDaemonNetworkMsg_Crash( 150 SendToNetwork(new ChromotingDaemonNetworkMsg_Crash(
147 location.function_name(), location.file_name(), location.line_number())); 151 location.function_name(), location.file_name(), location.line_number()));
Wez 2013/03/04 23:17:09 nit: You're not closing the IPC channel here, so D
alexeypa (please no reviews) 2013/03/05 00:01:44 Agree. The current implementation does not enforce
152
153 DeleteAllDesktopSessions();
Wez 2013/02/28 23:53:14 nit: We should really tear-down the IPC channel to
alexeypa (please no reviews) 2013/03/05 00:01:44 Agree, but let's do it as a separate CL. I imagine
Wez 2013/03/05 02:12:31 SGTM.
148 } 154 }
149 155
150 void DaemonProcess::Initialize() { 156 void DaemonProcess::Initialize() {
151 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 157 DCHECK(caller_task_runner()->BelongsToCurrentThread());
152 158
153 // Get the name of the host configuration file. 159 // Get the name of the host configuration file.
154 base::FilePath default_config_dir = remoting::GetConfigDir(); 160 base::FilePath default_config_dir = remoting::GetConfigDir();
155 base::FilePath config_path = default_config_dir.Append(kDefaultHostConfigFile) ; 161 base::FilePath config_path = default_config_dir.Append(kDefaultHostConfigFile) ;
156 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 162 const CommandLine* command_line = CommandLine::ForCurrentProcess();
157 if (command_line->HasSwitch(kHostConfigSwitchName)) { 163 if (command_line->HasSwitch(kHostConfigSwitchName)) {
(...skipping 20 matching lines...) Expand all
178 } 184 }
179 185
180 void DaemonProcess::DeleteAllDesktopSessions() { 186 void DaemonProcess::DeleteAllDesktopSessions() {
181 while (!desktop_sessions_.empty()) { 187 while (!desktop_sessions_.empty()) {
182 delete desktop_sessions_.front(); 188 delete desktop_sessions_.front();
183 desktop_sessions_.pop_front(); 189 desktop_sessions_.pop_front();
184 } 190 }
185 } 191 }
186 192
187 } // namespace remoting 193 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/desktop_process.cc » ('j') | remoting/host/desktop_process.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698