OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Parse the data returned from the SafeBrowsing v2.1 protocol response. | 5 // Parse the data returned from the SafeBrowsing v2.1 protocol response. |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 data += offset; | 59 data += offset; |
60 length -= offset; | 60 length -= offset; |
61 | 61 |
62 std::vector<std::string> cmd_parts; | 62 std::vector<std::string> cmd_parts; |
63 base::SplitString(line, ':', &cmd_parts); | 63 base::SplitString(line, ':', &cmd_parts); |
64 if (cmd_parts.size() != 3) | 64 if (cmd_parts.size() != 3) |
65 return false; | 65 return false; |
66 | 66 |
67 SBFullHashResult full_hash; | 67 SBFullHashResult full_hash; |
68 full_hash.list_name = cmd_parts[0]; | 68 full_hash.list_name = cmd_parts[0]; |
69 full_hash.add_chunk_id = atoi(cmd_parts[1].c_str()); | 69 // Ignore cmd_parts[1] (add_chunk_id), as we no longer use it with SB 2.3 |
| 70 // caching rules. |
70 int full_hash_len = atoi(cmd_parts[2].c_str()); | 71 int full_hash_len = atoi(cmd_parts[2].c_str()); |
71 | 72 |
72 // Ignore hash results from lists we don't recognize. | 73 // Ignore hash results from lists we don't recognize. |
73 if (safe_browsing_util::GetListId(full_hash.list_name) < 0) { | 74 if (safe_browsing_util::GetListId(full_hash.list_name) < 0) { |
74 data += full_hash_len; | 75 data += full_hash_len; |
75 length -= full_hash_len; | 76 length -= full_hash_len; |
76 continue; | 77 continue; |
77 } | 78 } |
78 | 79 |
79 while (full_hash_len > 0) { | 80 while (full_hash_len > 0) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 memcpy(&hash, *data, sizeof(hash)); | 415 memcpy(&hash, *data, sizeof(hash)); |
415 entry->SetFullHashAt(i, hash); | 416 entry->SetFullHashAt(i, hash); |
416 } | 417 } |
417 *data += hash_len; | 418 *data += hash_len; |
418 *remaining -= hash_len; | 419 *remaining -= hash_len; |
419 DCHECK_GE(*remaining, 0); | 420 DCHECK_GE(*remaining, 0); |
420 } | 421 } |
421 | 422 |
422 return true; | 423 return true; |
423 } | 424 } |
OLD | NEW |