OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/dns_util.h" | 5 #include "net/base/dns_util.h" |
6 | 6 |
| 7 #include <cstring> |
| 8 |
7 namespace net { | 9 namespace net { |
8 | 10 |
9 // Based on DJB's public domain code. | 11 // Based on DJB's public domain code. |
10 bool DNSDomainFromDot(const std::string& dotted, std::string* out) { | 12 bool DNSDomainFromDot(const std::string& dotted, std::string* out) { |
11 const char* buf = dotted.data(); | 13 const char* buf = dotted.data(); |
12 unsigned n = dotted.size(); | 14 unsigned n = dotted.size(); |
13 char label[63]; | 15 char label[63]; |
14 unsigned int labellen = 0; /* <= sizeof label */ | 16 unsigned int labellen = 0; /* <= sizeof label */ |
15 char name[255]; | 17 char name[255]; |
16 unsigned int namelen = 0; /* <= sizeof name */ | 18 unsigned int namelen = 0; /* <= sizeof name */ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (c >= 0x2e && c <= 0x2f) | 64 if (c >= 0x2e && c <= 0x2f) |
63 return false; | 65 return false; |
64 if (c >= 0x3a && c <= 0x40) | 66 if (c >= 0x3a && c <= 0x40) |
65 return false; | 67 return false; |
66 if (c >= 0x5b && c <= 0x60) | 68 if (c >= 0x5b && c <= 0x60) |
67 return false; | 69 return false; |
68 return true; | 70 return true; |
69 } | 71 } |
70 | 72 |
71 } // namespace net | 73 } // namespace net |
OLD | NEW |