diff options
author | xhwang <xhwang@chromium.org> | 2014-10-02 19:40:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-03 02:40:44 +0000 |
commit | 0d1882c21c2296a90ce259ef5e732662f946226b (patch) | |
tree | 83abf890c6b09d21509000193a1850caae60560c /components/component_updater/default_component_installer.cc | |
parent | 5aa22b960e030b7064afe5fd93f033a1ce321c57 (diff) | |
download | chromium_src-0d1882c21c2296a90ce259ef5e732662f946226b.zip chromium_src-0d1882c21c2296a90ce259ef5e732662f946226b.tar.gz chromium_src-0d1882c21c2296a90ce259ef5e732662f946226b.tar.bz2 |
Component Installer: Check manifest in VerifyInstallation().
Details:
- Check manifest in VerifyInstallation().
- Only check VerifyInstallation() for the latest folder found. Since we are only
trying to catch abnormal cases, this should be fine.
BUG=419582
Review URL: https://codereview.chromium.org/604373007
Cr-Commit-Position: refs/heads/master@{#297975}
Diffstat (limited to 'components/component_updater/default_component_installer.cc')
-rw-r--r-- | components/component_updater/default_component_installer.cc | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/components/component_updater/default_component_installer.cc b/components/component_updater/default_component_installer.cc index 847ce62..0e416d1 100644 --- a/components/component_updater/default_component_installer.cc +++ b/components/component_updater/default_component_installer.cc @@ -68,7 +68,7 @@ bool DefaultComponentInstaller::InstallHelper( return false; if (!installer_traits_->OnCustomInstall(manifest, install_path)) return false; - if (!installer_traits_->VerifyInstallation(install_path)) + if (!installer_traits_->VerifyInstallation(manifest, install_path)) return false; return true; } @@ -133,6 +133,8 @@ void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) { base::FilePath latest_dir; base::Version latest_version(kNullVersion); + scoped_ptr<base::DictionaryValue> latest_manifest; + std::vector<base::FilePath> older_dirs; bool found = false; base::FileEnumerator file_enumerator( @@ -141,45 +143,46 @@ void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) { !path.value().empty(); path = file_enumerator.Next()) { base::Version version(path.BaseName().MaybeAsASCII()); + // Ignore folders that don't have valid version names. These folders are not // managed by component installer so do not try to remove them. if (!version.IsValid()) continue; - if (!installer_traits_->VerifyInstallation(path)) { + + scoped_ptr<base::DictionaryValue> manifest = ReadManifest(path); + if (!manifest || !installer_traits_->VerifyInstallation(*manifest, path)) { + DLOG(ERROR) << "Failed to read manifest or verify installation for " + << installer_traits_->GetName() << " (" + << path.MaybeAsASCII() << ")."; older_dirs.push_back(path); continue; } + if (found) { if (version.CompareTo(latest_version) > 0) { older_dirs.push_back(latest_dir); + latest_dir = path; latest_version = version; + latest_manifest = manifest.Pass(); } else { older_dirs.push_back(path); } } else { latest_dir = path; latest_version = version; + latest_manifest = manifest.Pass(); found = true; } } if (found) { - current_manifest_ = ReadManifest(latest_dir); - if (current_manifest_) { - current_version_ = latest_version; - // TODO(ddorwin): Remove these members and pass them directly to - // FinishRegistration(). - base::ReadFileToString(latest_dir.AppendASCII("manifest.fingerprint"), - ¤t_fingerprint_); - } else { - // If the manifest can't be read, mark the directory for deletion and - // continue as if there were no versioned directories at all. - DLOG(ERROR) << "Failed to read manifest for " - << installer_traits_->GetName() << " (" - << base_dir.MaybeAsASCII() << ")."; - older_dirs.push_back(latest_dir); - } + current_version_ = latest_version; + current_manifest_ = latest_manifest.Pass(); + // TODO(ddorwin): Remove these members and pass them directly to + // FinishRegistration(). + base::ReadFileToString(latest_dir.AppendASCII("manifest.fingerprint"), + ¤t_fingerprint_); } // Remove older versions of the component. None should be in use during |