| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/safe_browsing/protocol_parser.h" | 7 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
| 12 #include <Winsock2.h> | 12 #include <Winsock2.h> |
| 13 #elif defined(OS_POSIX) | 13 #elif defined(OS_POSIX) |
| 14 #include <arpa/inet.h> | 14 #include <arpa/inet.h> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #include "base/format_macros.h" | 17 #include "base/format_macros.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/string_split.h" |
| 19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 // Helper function for quick scans of a line oriented protocol. Note that we use | 23 // Helper function for quick scans of a line oriented protocol. Note that we use |
| 23 // std::string::assign(const charT* s, size_type n) | 24 // std::string::assign(const charT* s, size_type n) |
| 24 // to copy data into 'line'. This form of 'assign' does not call strlen on | 25 // to copy data into 'line'. This form of 'assign' does not call strlen on |
| 25 // 'input', which is binary data and is not NULL terminated. 'input' may also | 26 // 'input', which is binary data and is not NULL terminated. 'input' may also |
| 26 // contain valid NULL bytes in the payload, which a strlen based copy would | 27 // contain valid NULL bytes in the payload, which a strlen based copy would |
| 27 // truncate. | 28 // truncate. |
| 28 bool GetLine(const char* input, int input_len, std::string* line) { | 29 bool GetLine(const char* input, int input_len, std::string* line) { |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 484 |
| 484 data += line.size() + 1; | 485 data += line.size() + 1; |
| 485 remaining -= static_cast<int>(line.size()) + 1; | 486 remaining -= static_cast<int>(line.size()) + 1; |
| 486 } | 487 } |
| 487 | 488 |
| 488 if (client_key->empty() || wrapped_key->empty()) | 489 if (client_key->empty() || wrapped_key->empty()) |
| 489 return false; | 490 return false; |
| 490 | 491 |
| 491 return true; | 492 return true; |
| 492 } | 493 } |
| OLD | NEW |