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

Side by Side Diff: chrome/browser/ui/webui/favicon_source.cc

Issue 11576030: Add size checks to extension icons to prevent out of memory conditions (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 (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/browser/ui/webui/favicon_source.h" 5 #include "chrome/browser/ui/webui/favicon_source.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 "chrome/browser/favicon/favicon_service_factory.h" 9 #include "chrome/browser/favicon/favicon_service_factory.h"
10 #include "chrome/browser/history/top_sites.h" 10 #include "chrome/browser/history/top_sites.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 base::Unretained(this), 75 base::Unretained(this),
76 IconRequest(request_id, size_in_dip, scale_factor)), 76 IconRequest(request_id, size_in_dip, scale_factor)),
77 &cancelable_task_tracker_); 77 &cancelable_task_tracker_);
78 } else { 78 } else {
79 GURL url; 79 GURL url;
80 if (path.size() > 5 && path.substr(0, 5) == "size/") { 80 if (path.size() > 5 && path.substr(0, 5) == "size/") {
81 size_t slash = path.find("/", 5); 81 size_t slash = path.find("/", 5);
82 size_t scale_delimiter = path.find("@", 5); 82 size_t scale_delimiter = path.find("@", 5);
83 std::string size = path.substr(5, slash - 5); 83 std::string size = path.substr(5, slash - 5);
84 size_in_dip = atoi(size.c_str()); 84 size_in_dip = atoi(size.c_str());
85 DCHECK(size_in_dip == 64 || size_in_dip == 32 || size_in_dip == 16) << 85 if (size_in_dip != 64 && size_in_dip != 32 && size_in_dip != 16) {
86 "only 64x64, 32x32 and 16x16 icons are supported"; 86 // Only 64x64, 32x32 and 16x16 icons are supported
87 size_in_dip = 16;
Mustafa Acer 2012/12/14 19:29:25 I'm hoping this won't break any case where a size
Matt Perry 2012/12/14 19:33:44 If we used sizes like that anywhere, we should hav
88 }
87 // Optional scale factor. 89 // Optional scale factor.
88 if (scale_delimiter != std::string::npos && scale_delimiter < slash) { 90 if (scale_delimiter != std::string::npos && scale_delimiter < slash) {
89 DCHECK(size_in_dip == 16); 91 DCHECK(size_in_dip == 16);
90 std::string scale_str = path.substr(scale_delimiter + 1, 92 std::string scale_str = path.substr(scale_delimiter + 1,
91 slash - scale_delimiter - 1); 93 slash - scale_delimiter - 1);
92 web_ui_util::ParseScaleFactor(scale_str, &scale_factor); 94 web_ui_util::ParseScaleFactor(scale_str, &scale_factor);
93 } 95 }
94 url = GURL(path.substr(slash + 1)); 96 url = GURL(path.substr(slash + 1));
95 } else { 97 } else {
96 // URL requests prefixed with "origin/" are converted to a form with an 98 // URL requests prefixed with "origin/" are converted to a form with an
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 180
179 if (!default_favicon) { 181 if (!default_favicon) {
180 ui::ScaleFactor scale_factor = icon_request.scale_factor; 182 ui::ScaleFactor scale_factor = icon_request.scale_factor;
181 default_favicon = ResourceBundle::GetSharedInstance() 183 default_favicon = ResourceBundle::GetSharedInstance()
182 .LoadDataResourceBytesForScale(resource_id, scale_factor); 184 .LoadDataResourceBytesForScale(resource_id, scale_factor);
183 default_favicons_[favicon_index] = default_favicon; 185 default_favicons_[favicon_index] = default_favicon;
184 } 186 }
185 187
186 SendResponse(icon_request.request_id, default_favicon); 188 SendResponse(icon_request.request_id, default_favicon);
187 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698