OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "third_party/hunspell_new/google/bdict.h" | 5 #include "third_party/hunspell/google/bdict.h" |
6 | 6 |
7 // static | 7 // static |
8 bool hunspell::BDict::Verify(const char* bdict_data, size_t bdict_length) { | 8 bool hunspell::BDict::Verify(const char* bdict_data, size_t bdict_length) { |
9 if (bdict_length <= sizeof(hunspell::BDict::Header)) | 9 if (bdict_length <= sizeof(hunspell::BDict::Header)) |
10 return false; | 10 return false; |
11 | 11 |
12 const BDict::Header* header = | 12 const BDict::Header* header = |
13 reinterpret_cast<const hunspell::BDict::Header*>(bdict_data); | 13 reinterpret_cast<const hunspell::BDict::Header*>(bdict_data); |
14 if (header->signature != hunspell::BDict::SIGNATURE || | 14 if (header->signature != hunspell::BDict::SIGNATURE || |
15 header->major_version > hunspell::BDict::MAJOR_VERSION || | 15 header->major_version > hunspell::BDict::MAJOR_VERSION || |
(...skipping 15 matching lines...) Expand all Loading... |
31 // MD5 digest of the data with the one in the BDICT header. | 31 // MD5 digest of the data with the one in the BDICT header. |
32 if (header->major_version >= 2) { | 32 if (header->major_version >= 2) { |
33 base::MD5Digest digest; | 33 base::MD5Digest digest; |
34 base::MD5Sum(aff_header, bdict_length - header->aff_offset, &digest); | 34 base::MD5Sum(aff_header, bdict_length - header->aff_offset, &digest); |
35 if (memcmp(&digest, &header->digest, sizeof(digest))) | 35 if (memcmp(&digest, &header->digest, sizeof(digest))) |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 return true; | 39 return true; |
40 } | 40 } |
OLD | NEW |