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

Side by Side Diff: third_party/hunspell/google/bdict.cc

Issue 4409002: Add a MD5 checksum to the BDIC header.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/hunspell/google/bdict.h ('k') | third_party/hunspell/google/bdict_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "third_party/hunspell/google/bdict.h"
6
7 // static
8 bool hunspell::BDict::Verify(const char* bdict_data, size_t bdict_length) {
9 if (bdict_length <= sizeof(hunspell::BDict::Header))
10 return false;
11
12 const BDict::Header* header =
13 reinterpret_cast<const hunspell::BDict::Header*>(bdict_data);
14 if (header->signature != hunspell::BDict::SIGNATURE ||
15 header->major_version > hunspell::BDict::MAJOR_VERSION ||
16 header->dic_offset > bdict_length)
17 return false;
18
19 // Get the affix header, make sure there is enough room for it.
20 if (header->aff_offset + sizeof(hunspell::BDict::AffHeader) > bdict_length)
21 return false;
22
23 // Make sure there is enough room for the affix group count dword.
24 const hunspell::BDict::AffHeader* aff_header =
25 reinterpret_cast<const hunspell::BDict::AffHeader*>(
26 &bdict_data[header->aff_offset]);
27 if (aff_header->affix_group_offset + sizeof(uint32) > bdict_length)
28 return false;
29
30 // The new BDICT header has a MD5 digest of the dictionary data. Compare the
31 // MD5 digest of the data with the one in the BDICT header.
32 if (header->major_version >= 2) {
33 MD5Digest digest;
34 MD5Sum(aff_header, bdict_length - header->aff_offset, &digest);
35 if (memcmp(&digest, &header->digest, sizeof(digest)))
36 return false;
37 }
38
39 return true;
40 }
OLDNEW
« no previous file with comments | « third_party/hunspell/google/bdict.h ('k') | third_party/hunspell/google/bdict_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698