Index: chrome/browser/component_updater/supervised_user_whitelist_installer.cc |
diff --git a/chrome/browser/component_updater/supervised_user_whitelist_installer.cc b/chrome/browser/component_updater/supervised_user_whitelist_installer.cc |
index 7989e954670c5299bc7360235a9be67af803ac1e..2fe544d6886ea22c1664ca9fc8817f13f0f486b7 100644 |
--- a/chrome/browser/component_updater/supervised_user_whitelist_installer.cc |
+++ b/chrome/browser/component_updater/supervised_user_whitelist_installer.cc |
@@ -66,36 +66,38 @@ base::string16 GetWhitelistTitle(const base::DictionaryValue& manifest) { |
return title; |
} |
-base::FilePath GetLargeIconPath(const base::DictionaryValue& manifest, |
- const base::FilePath& install_dir) { |
- const base::DictionaryValue* icons = nullptr; |
- if (!manifest.GetDictionary(kExtensionIcons, &icons)) |
- return base::FilePath(); |
- |
- base::FilePath path; |
+base::FilePath GetSafeFilePath(const base::DictionaryValue& dictionary, |
+ const std::string& key, |
+ const base::FilePath& install_dir) { |
const base::Value* path_value = nullptr; |
- if (!icons->Get(kExtensionLargeIcon, &path_value)) |
+ if (!dictionary.Get(key, &path_value)) |
return base::FilePath(); |
+ base::FilePath path; |
if (!base::GetValueAsFilePath(*path_value, &path)) |
return base::FilePath(); |
+ // Path components ("..") are not allowed. |
+ if (path.ReferencesParent()) |
+ return base::FilePath(); |
return install_dir.Append(path); |
} |
+base::FilePath GetLargeIconPath(const base::DictionaryValue& manifest, |
+ const base::FilePath& install_dir) { |
+ const base::DictionaryValue* icons = nullptr; |
+ if (!manifest.GetDictionary(kExtensionIcons, &icons)) |
+ return base::FilePath(); |
+ |
+ return GetSafeFilePath(*icons, kExtensionLargeIcon, install_dir); |
+} |
+ |
base::FilePath GetRawWhitelistPath(const base::DictionaryValue& manifest, |
const base::FilePath& install_dir) { |
const base::DictionaryValue* whitelist_dict = nullptr; |
if (!manifest.GetDictionary(kWhitelistedContent, &whitelist_dict)) |
return base::FilePath(); |
- base::FilePath whitelist_file; |
- const base::Value* whitelist_file_value = nullptr; |
- if (!whitelist_dict->Get(kSites, &whitelist_file_value)) |
- return base::FilePath(); |
- if (!base::GetValueAsFilePath(*whitelist_file_value, &whitelist_file)) |
- return base::FilePath(); |
- |
- return install_dir.Append(whitelist_file); |
+ return GetSafeFilePath(*whitelist_dict, kSites, install_dir); |
} |
base::FilePath GetSanitizedWhitelistPath(const std::string& crx_id) { |