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

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 1951213002: Avoid incrementing an invalid iterator in the utility process client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 "chrome/utility/chrome_content_utility_client.h" 5 #include "chrome/utility/chrome_content_utility_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeDmgFileForDownloadProtection, 168 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeDmgFileForDownloadProtection,
169 OnAnalyzeDmgFileForDownloadProtection) 169 OnAnalyzeDmgFileForDownloadProtection)
170 #endif // defined(OS_MACOSX) 170 #endif // defined(OS_MACOSX)
171 #endif // defined(FULL_SAFE_BROWSING) 171 #endif // defined(FULL_SAFE_BROWSING)
172 #if defined(OS_CHROMEOS) 172 #if defined(OS_CHROMEOS)
173 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) 173 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile)
174 #endif 174 #endif
175 IPC_MESSAGE_UNHANDLED(handled = false) 175 IPC_MESSAGE_UNHANDLED(handled = false)
176 IPC_END_MESSAGE_MAP() 176 IPC_END_MESSAGE_MAP()
177 177
178 for (Handlers::iterator it = handlers_.begin(); 178 if (handled)
179 !handled && it != handlers_.end(); ++it) { 179 return true;
180 handled = (*it)->OnMessageReceived(message); 180
181 for (const auto& handler : handlers_) {
182 // At least one of the utility process handlers adds a new handler to
183 // |handlers_| when it handles a message. This causes any iterator over
184 // |handlers_| to become invalid. Therefore, it is necessary to break the
185 // loop at this point instead of evaluating it as a loop condition (if the
186 // for loop was using iterators explicitly, as originally done).
187 if (handler->OnMessageReceived(message))
188 return true;
181 } 189 }
182 190
183 return handled; 191 return false;
184 } 192 }
185 193
186 void ChromeContentUtilityClient::RegisterMojoServices( 194 void ChromeContentUtilityClient::RegisterMojoServices(
187 content::ServiceRegistry* registry) { 195 content::ServiceRegistry* registry) {
188 // When the utility process is running with elevated privileges, we need to 196 // When the utility process is running with elevated privileges, we need to
189 // filter messages so that only a whitelist of IPCs can run. In Mojo, there's 197 // filter messages so that only a whitelist of IPCs can run. In Mojo, there's
190 // no way of filtering individual messages. Instead, we can avoid adding 198 // no way of filtering individual messages. Instead, we can avoid adding
191 // non-whitelisted Mojo services to the ServiceRegistry. 199 // non-whitelisted Mojo services to the ServiceRegistry.
192 // TODO(amistry): Use a whitelist once the whistlisted IPCs have been 200 // TODO(amistry): Use a whitelist once the whistlisted IPCs have been
193 // converted to Mojo. 201 // converted to Mojo.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 safe_browsing::zip_analyzer::Results results; 304 safe_browsing::zip_analyzer::Results results;
297 safe_browsing::dmg::AnalyzeDMGFile( 305 safe_browsing::dmg::AnalyzeDMGFile(
298 IPC::PlatformFileForTransitToFile(dmg_file), &results); 306 IPC::PlatformFileForTransitToFile(dmg_file), &results);
299 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( 307 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished(
300 results)); 308 results));
301 ReleaseProcessIfNeeded(); 309 ReleaseProcessIfNeeded();
302 } 310 }
303 #endif // defined(OS_MACOSX) 311 #endif // defined(OS_MACOSX)
304 312
305 #endif // defined(FULL_SAFE_BROWSING) 313 #endif // defined(FULL_SAFE_BROWSING)
OLDNEW
« 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