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 // 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" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
| 13 #include "base/sys_byteorder.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "chrome/browser/safe_browsing/protocol_parser.h" | 15 #include "chrome/browser/safe_browsing/protocol_parser.h" |
15 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
16 | 17 |
17 #if defined(OS_WIN) | |
18 #include <Winsock2.h> | |
19 #elif defined(OS_POSIX) | |
20 #include <arpa/inet.h> | |
21 #endif | |
22 | |
23 namespace { | 18 namespace { |
24 // Helper function for quick scans of a line oriented protocol. Note that we use | 19 // Helper function for quick scans of a line oriented protocol. Note that we use |
25 // std::string::assign(const charT* s, size_type n) | 20 // std::string::assign(const charT* s, size_type n) |
26 // to copy data into 'line'. This form of 'assign' does not call strlen on | 21 // to copy data into 'line'. This form of 'assign' does not call strlen on |
27 // 'input', which is binary data and is not NULL terminated. 'input' may also | 22 // 'input', which is binary data and is not NULL terminated. 'input' may also |
28 // contain valid NULL bytes in the payload, which a strlen based copy would | 23 // contain valid NULL bytes in the payload, which a strlen based copy would |
29 // truncate. | 24 // truncate. |
30 bool GetLine(const char* input, int input_len, std::string* line) { | 25 bool GetLine(const char* input, int input_len, std::string* line) { |
31 const char* pos = input; | 26 const char* pos = input; |
32 while (pos && (pos - input < input_len)) { | 27 while (pos && (pos - input < input_len)) { |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 514 |
520 data += line.size() + 1; | 515 data += line.size() + 1; |
521 remaining -= static_cast<int>(line.size()) + 1; | 516 remaining -= static_cast<int>(line.size()) + 1; |
522 } | 517 } |
523 | 518 |
524 if (client_key->empty() || wrapped_key->empty()) | 519 if (client_key->empty() || wrapped_key->empty()) |
525 return false; | 520 return false; |
526 | 521 |
527 return true; | 522 return true; |
528 } | 523 } |
OLD | NEW |