Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: net/dns/dns_config_service.cc

Issue 10833017: Fix gcc 4.7 building problems - cont 2. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "net/dns/dns_config_service.h" 5 #include "net/dns/dns_config_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 namespace { 14 namespace {
15 15
16 // Check if particular nameserver address is rogue. See: 16 // Check if particular nameserver address is rogue. See:
17 // http://www.fbi.gov/news/stories/2011/november/malware_110911/DNS-changer-malw are.pdf 17 // http://www.fbi.gov/news/stories/2011/november/malware_110911/DNS-changer-malw are.pdf
18 bool CheckRogueDnsAddress(const IPAddressNumber& address) { 18 bool CheckRogueDnsAddress(const IPAddressNumber& address) {
19 #define _C_(x) static_cast<unsigned char>(x)
agl 2012/07/25 20:32:34 _C_ is an odd name for a macro. How about U8?
Han 2012/07/25 22:28:44 Done.
19 const struct Bounds { 20 const struct Bounds {
20 const unsigned char lower[4]; // inclusive 21 const unsigned char lower[4]; // inclusive
21 const unsigned char upper[4]; // exclusive 22 const unsigned char upper[4]; // exclusive
22 } cases[] = { 23 } cases[] = {
23 { { '\x55', '\xFF', '\x70', '\x00' }, // 85.255.112.0 24 { { _C_('\x55'), _C_('\xFF'), _C_('\x70'), _C_('\x00') }, // 85.255.112.0
24 { '\x55', '\xFF', '\x80', '\x00' } }, // 85.255.128.0 25 { _C_('\x55'), _C_('\xFF'), _C_('\x80'), _C_('\x00') } }, // 85.255.128.0
25 { { '\x43', '\xD2', '\x00', '\x00' }, // 67.210.0.0 26 { { _C_('\x43'), _C_('\xD2'), _C_('\x00'), _C_('\x00') }, // 67.210.0.0
26 { '\x43', '\xD2', '\x10', '\x00' } }, // 67.210.16.0 27 { _C_('\x43'), _C_('\xD2'), _C_('\x10'), _C_('\x00') } }, // 67.210.16.0
27 { { '\x5D', '\xBC', '\xA0', '\x00' }, // 93.188.160.0 28 { { _C_('\x5D'), _C_('\xBC'), _C_('\xA0'), _C_('\x00') }, // 93.188.160.0
28 { '\x5D', '\xBC', '\xA8', '\x00' } }, // 93.188.168.0 29 { _C_('\x5D'), _C_('\xBC'), _C_('\xA8'), _C_('\x00') } }, // 93.188.168.0
29 { { '\x4D', '\x43', '\x53', '\x00' }, // 77.67.83.0 30 { { _C_('\x4D'), _C_('\x43'), _C_('\x53'), _C_('\x00') }, // 77.67.83.0
30 { '\x4D', '\x43', '\x54', '\x00' } }, // 77.67.84.0 31 { _C_('\x4D'), _C_('\x43'), _C_('\x54'), _C_('\x00') } }, // 77.67.84.0
31 { { '\x40', '\x1C', '\xB2', '\x00' }, // 64.28.178.0 32 { { _C_('\x40'), _C_('\x1C'), _C_('\xB2'), _C_('\x00') }, // 64.28.178.0
32 { '\x40', '\x1C', '\xC0', '\x00' } }, // 64.28.192.0 33 { _C_('\x40'), _C_('\x1C'), _C_('\xC0'), _C_('\x00') } }, // 64.28.192.0
33 }; 34 };
35 #undef _C_
34 for (unsigned i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 36 for (unsigned i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
35 const Bounds& bounds = cases[i]; 37 const Bounds& bounds = cases[i];
36 IPAddressNumber lower(bounds.lower, bounds.lower + 4); 38 IPAddressNumber lower(bounds.lower, bounds.lower + 4);
37 IPAddressNumber upper(bounds.upper, bounds.upper + 4); 39 IPAddressNumber upper(bounds.upper, bounds.upper + 4);
38 if (address.size() == kIPv6AddressSize) { 40 if (address.size() == kIPv6AddressSize) {
39 lower = ConvertIPv4NumberToIPv6Number(lower); 41 lower = ConvertIPv4NumberToIPv6Number(lower);
40 upper = ConvertIPv4NumberToIPv6Number(upper); 42 upper = ConvertIPv4NumberToIPv6Number(upper);
41 } 43 }
42 if ((lower <= address) && (address < upper)) 44 if ((lower <= address) && (address < upper))
43 return true; 45 return true;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 CheckRogueDnsConfig(dns_config_); 266 CheckRogueDnsConfig(dns_config_);
265 checked_rogue_dns_ = true; 267 checked_rogue_dns_ = true;
266 } 268 }
267 need_update_ = false; 269 need_update_ = false;
268 last_sent_empty_ = false; 270 last_sent_empty_ = false;
269 callback_.Run(dns_config_); 271 callback_.Run(dns_config_);
270 } 272 }
271 273
272 } // namespace net 274 } // namespace net
273 275
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698