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

Side by Side Diff: webkit/plugins/npapi/plugin_group.cc

Issue 6579004: Don't access WebPluginInfo array out of bounds in PluginGroup::RemovePlugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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 | webkit/plugins/npapi/plugin_group_unittest.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "webkit/plugins/npapi/plugin_group.h" 7 #include "webkit/plugins/npapi/plugin_group.h"
8 8
9 #include "base/linked_ptr.h" 9 #include "base/linked_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 web_plugin_infos_.push_back(plugin); 242 web_plugin_infos_.push_back(plugin);
243 UpdateActivePlugin(web_plugin_infos_.back()); 243 UpdateActivePlugin(web_plugin_infos_.back());
244 } 244 }
245 245
246 bool PluginGroup::RemovePlugin(const FilePath& filename) { 246 bool PluginGroup::RemovePlugin(const FilePath& filename) {
247 bool did_remove = false; 247 bool did_remove = false;
248 ResetGroupState(); 248 ResetGroupState();
249 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { 249 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) {
250 if (web_plugin_infos_[i].path == filename) { 250 if (web_plugin_infos_[i].path == filename) {
251 web_plugin_infos_.erase(web_plugin_infos_.begin() + i); 251 web_plugin_infos_.erase(web_plugin_infos_.begin() + i--);
jam 2011/02/23 19:49:59 nit: usually i've seen this be done by not having
252 did_remove = true; 252 did_remove = true;
253 } else {
254 UpdateActivePlugin(web_plugin_infos_[i]);
253 } 255 }
254 UpdateActivePlugin(web_plugin_infos_[i]);
255 } 256 }
256 return did_remove; 257 return did_remove;
257 } 258 }
258 259
259 bool PluginGroup::EnablePlugin(const FilePath& filename) { 260 bool PluginGroup::EnablePlugin(const FilePath& filename) {
260 bool did_enable = false; 261 bool did_enable = false;
261 ResetGroupState(); 262 ResetGroupState();
262 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { 263 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) {
263 if (web_plugin_infos_[i].path == filename) 264 if (web_plugin_infos_[i].path == filename)
264 did_enable = Enable(&web_plugin_infos_[i], WebPluginInfo::USER_ENABLED); 265 did_enable = Enable(&web_plugin_infos_[i], WebPluginInfo::USER_ENABLED);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // Only changeable if not managed. 522 // Only changeable if not managed.
522 if (plugin->enabled & WebPluginInfo::MANAGED_MASK) 523 if (plugin->enabled & WebPluginInfo::MANAGED_MASK)
523 return false; 524 return false;
524 plugin->enabled = new_reason; 525 plugin->enabled = new_reason;
525 } 526 }
526 return true; 527 return true;
527 } 528 }
528 529
529 } // namespace npapi 530 } // namespace npapi
530 } // namespace webkit 531 } // namespace webkit
OLDNEW
« no previous file with comments | « no previous file | webkit/plugins/npapi/plugin_group_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698