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 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 size_t prefix_size = static_cast<uint8_t>(full_hash[base::kSHA1Length]); | 1828 size_t prefix_size = static_cast<uint8_t>(full_hash[base::kSHA1Length]); |
1829 if (prefix_size > kMaxIpPrefixSize || prefix_size < kMinIpPrefixSize) { | 1829 if (prefix_size > kMaxIpPrefixSize || prefix_size < kMinIpPrefixSize) { |
1830 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_INVALID); | 1830 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_INVALID); |
1831 new_blacklist.clear(); // Load empty blacklist. | 1831 new_blacklist.clear(); // Load empty blacklist. |
1832 break; | 1832 break; |
1833 } | 1833 } |
1834 | 1834 |
1835 // We precompute the mask for the given subnet size to speed up lookups. | 1835 // We precompute the mask for the given subnet size to speed up lookups. |
1836 // Basically we need to create a 16B long string which has the highest | 1836 // Basically we need to create a 16B long string which has the highest |
1837 // |size| bits sets to one. | 1837 // |size| bits sets to one. |
1838 std::string mask(net::kIPv6AddressSize, '\0'); | 1838 std::string mask(net::IPAddress::kIPv6AddressSize, '\0'); |
1839 mask.replace(0, prefix_size / 8, prefix_size / 8, '\xFF'); | 1839 mask.replace(0, prefix_size / 8, prefix_size / 8, '\xFF'); |
1840 if ((prefix_size % 8) != 0) { | 1840 if ((prefix_size % 8) != 0) { |
1841 mask[prefix_size / 8] = 0xFF << (8 - (prefix_size % 8)); | 1841 mask[prefix_size / 8] = 0xFF << (8 - (prefix_size % 8)); |
1842 } | 1842 } |
1843 DVLOG(2) << "Inserting malicious IP: " | 1843 DVLOG(2) << "Inserting malicious IP: " |
1844 << " raw:" << base::HexEncode(full_hash, crypto::kSHA256Length) | 1844 << " raw:" << base::HexEncode(full_hash, crypto::kSHA256Length) |
1845 << " mask:" << base::HexEncode(mask.data(), mask.size()) | 1845 << " mask:" << base::HexEncode(mask.data(), mask.size()) |
1846 << " prefix_size:" << prefix_size | 1846 << " prefix_size:" << prefix_size |
1847 << " hashed_ip:" << base::HexEncode(hashed_ip_prefix.data(), | 1847 << " hashed_ip:" << base::HexEncode(hashed_ip_prefix.data(), |
1848 hashed_ip_prefix.size()); | 1848 hashed_ip_prefix.size()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 | 1927 |
1928 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. | 1928 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. |
1929 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( | 1929 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( |
1930 histogram_name, 1, 1000000, 50, | 1930 histogram_name, 1, 1000000, 50, |
1931 base::HistogramBase::kUmaTargetedHistogramFlag); | 1931 base::HistogramBase::kUmaTargetedHistogramFlag); |
1932 | 1932 |
1933 histogram_pointer->Add(file_size_kilobytes); | 1933 histogram_pointer->Add(file_size_kilobytes); |
1934 } | 1934 } |
1935 | 1935 |
1936 } // namespace safe_browsing | 1936 } // namespace safe_browsing |
OLD | NEW |