| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <Winsock2.h> | 10 #include <Winsock2.h> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 std::vector<std::string> cmd_parts; | 83 std::vector<std::string> cmd_parts; |
| 84 SplitString(line, ':', &cmd_parts); | 84 SplitString(line, ':', &cmd_parts); |
| 85 if (cmd_parts.size() != 3) | 85 if (cmd_parts.size() != 3) |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 SBFullHashResult full_hash; | 88 SBFullHashResult full_hash; |
| 89 full_hash.list_name = cmd_parts[0]; | 89 full_hash.list_name = cmd_parts[0]; |
| 90 full_hash.add_chunk_id = atoi(cmd_parts[1].c_str()); | 90 full_hash.add_chunk_id = atoi(cmd_parts[1].c_str()); |
| 91 int full_hash_len = atoi(cmd_parts[2].c_str()); | 91 int full_hash_len = atoi(cmd_parts[2].c_str()); |
| 92 | 92 |
| 93 // Ignore hash results from lists we don't recognize. |
| 94 if (safe_browsing_util::GetListId(full_hash.list_name) < 0) { |
| 95 data += full_hash_len; |
| 96 length -= full_hash_len; |
| 97 continue; |
| 98 } |
| 99 |
| 93 while (full_hash_len > 0) { | 100 while (full_hash_len > 0) { |
| 94 DCHECK(static_cast<size_t>(full_hash_len) >= sizeof(SBFullHash)); | 101 DCHECK(static_cast<size_t>(full_hash_len) >= sizeof(SBFullHash)); |
| 95 memcpy(&full_hash.hash, data, sizeof(SBFullHash)); | 102 memcpy(&full_hash.hash, data, sizeof(SBFullHash)); |
| 96 full_hashes->push_back(full_hash); | 103 full_hashes->push_back(full_hash); |
| 97 data += sizeof(SBFullHash); | 104 data += sizeof(SBFullHash); |
| 98 length -= sizeof(SBFullHash); | 105 length -= sizeof(SBFullHash); |
| 99 full_hash_len -= sizeof(SBFullHash); | 106 full_hash_len -= sizeof(SBFullHash); |
| 100 } | 107 } |
| 101 } | 108 } |
| 102 | 109 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 479 |
| 473 data += line.size() + 1; | 480 data += line.size() + 1; |
| 474 remaining -= static_cast<int>(line.size()) + 1; | 481 remaining -= static_cast<int>(line.size()) + 1; |
| 475 } | 482 } |
| 476 | 483 |
| 477 if (client_key->empty() || wrapped_key->empty()) | 484 if (client_key->empty() || wrapped_key->empty()) |
| 478 return false; | 485 return false; |
| 479 | 486 |
| 480 return true; | 487 return true; |
| 481 } | 488 } |
| OLD | NEW |