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

Unified Diff: chrome/browser/spellcheck_host.cc

Issue 4477002: Add sanity checks of the BDIC files to ConvertDictTest.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/tools/convert_dict/convert_dict_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/spellcheck_host.cc
===================================================================
--- chrome/browser/spellcheck_host.cc (revision 65173)
+++ chrome/browser/spellcheck_host.cc (working copy)
@@ -24,6 +24,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/spellcheck_common.h"
#include "googleurl/src/gurl.h"
+#include "third_party/hunspell/google/bdict.h"
namespace {
@@ -287,6 +288,16 @@
void SpellCheckHost::SaveDictionaryData() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ // To prevent corrupted dictionary data from causing a renderer crash, scan
+ // the dictionary data and verify it is sane before save it to a file.
+ if (!hunspell::BDict::Verify(data_.data(), data_.size())) {
+ LOG(ERROR) << "Failure to verify the downloaded dictionary.";
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(this,
+ &SpellCheckHost::InformObserverOfInitialization));
+ return;
+ }
+
size_t bytes_written =
file_util::WriteFile(bdict_file_path_, data_.data(), data_.length());
if (bytes_written != data_.length()) {
« no previous file with comments | « no previous file | chrome/tools/convert_dict/convert_dict_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698