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

Side by Side Diff: extensions/common/manifest_handler_helpers.cc

Issue 1618073002: Extensions - Check for too big or too small product icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/manifest_handler_helpers.h" 5 #include "extensions/common/manifest_handler_helpers.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "extensions/common/constants.h"
13 #include "extensions/common/error_utils.h" 14 #include "extensions/common/error_utils.h"
14 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
15 #include "extensions/common/extension_icon_set.h" 16 #include "extensions/common/extension_icon_set.h"
16 #include "extensions/common/manifest_constants.h" 17 #include "extensions/common/manifest_constants.h"
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 namespace errors = manifest_errors; 21 namespace errors = manifest_errors;
21 22
22 namespace manifest_handler_helpers { 23 namespace manifest_handler_helpers {
(...skipping 11 matching lines...) Expand all
34 35
35 bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, 36 bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value,
36 ExtensionIconSet* icons, 37 ExtensionIconSet* icons,
37 base::string16* error) { 38 base::string16* error) {
38 DCHECK(icons); 39 DCHECK(icons);
39 DCHECK(error); 40 DCHECK(error);
40 for (base::DictionaryValue::Iterator iterator(*icons_value); 41 for (base::DictionaryValue::Iterator iterator(*icons_value);
41 !iterator.IsAtEnd(); iterator.Advance()) { 42 !iterator.IsAtEnd(); iterator.Advance()) {
42 int size = 0; 43 int size = 0;
43 std::string icon_path; 44 std::string icon_path;
44 if (!base::StringToInt(iterator.key(), &size) || 45 if (!base::StringToInt(iterator.key(), &size) || size <= 0 ||
45 !iterator.value().GetAsString(&icon_path) || 46 size > extension_misc::EXTENSION_ICON_GIGANTOR * 4) {
47 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidIconKey,
48 iterator.key());
49 return false;
50 }
51 if (!iterator.value().GetAsString(&icon_path) ||
46 !NormalizeAndValidatePath(&icon_path)) { 52 !NormalizeAndValidatePath(&icon_path)) {
47 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidIconPath, 53 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidIconPath,
48 iterator.key()); 54 iterator.key());
49 return false; 55 return false;
50 } 56 }
51 57
52 icons->Add(size, icon_path); 58 icons->Add(size, icon_path);
53 } 59 }
54 return true; 60 return true;
55 } 61 }
56 62
57 } // namespace manifest_handler_helpers 63 } // namespace manifest_handler_helpers
58 64
59 } // namespace extensions 65 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_constants.cc ('k') | extensions/common/manifest_handlers/icons_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698