| 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" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/sys_byteorder.h" | 13 #include "base/sys_byteorder.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/safe_browsing/protocol_parser.h" | 15 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // 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 |
| 20 // std::string::assign(const charT* s, size_type n) | 20 // std::string::assign(const charT* s, size_type n) |
| 21 // 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 |
| 22 // '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 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 DCHECK_EQ(hash_len, (int)sizeof(SBFullHash)); | 407 DCHECK_EQ(hash_len, (int)sizeof(SBFullHash)); |
| 408 entry->SetFullHashAt(i, *reinterpret_cast<const SBFullHash*>(*data)); | 408 entry->SetFullHashAt(i, *reinterpret_cast<const SBFullHash*>(*data)); |
| 409 } | 409 } |
| 410 *data += hash_len; | 410 *data += hash_len; |
| 411 *remaining -= hash_len; | 411 *remaining -= hash_len; |
| 412 DCHECK_GE(*remaining, 0); | 412 DCHECK_GE(*remaining, 0); |
| 413 } | 413 } |
| 414 | 414 |
| 415 return true; | 415 return true; |
| 416 } | 416 } |
| OLD | NEW |