| 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 #include "net/dns/dns_util.h" | 5 #include "net/dns/dns_util.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 | 9 |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (namelen + 1 > sizeof name) | 76 if (namelen + 1 > sizeof name) |
| 77 return false; | 77 return false; |
| 78 if (namelen == 0) // Empty names e.g. "", "." are not valid. | 78 if (namelen == 0) // Empty names e.g. "", "." are not valid. |
| 79 return false; | 79 return false; |
| 80 name[namelen++] = 0; // This is the root label (of length 0). | 80 name[namelen++] = 0; // This is the root label (of length 0). |
| 81 | 81 |
| 82 *out = std::string(name, namelen); | 82 *out = std::string(name, namelen); |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool IsValidDNSDomain(const base::StringPiece& dotted) { |
| 87 std::string dns_formatted; |
| 88 return DNSDomainFromDot(dotted, &dns_formatted); |
| 89 } |
| 90 |
| 86 std::string DNSDomainToString(const base::StringPiece& domain) { | 91 std::string DNSDomainToString(const base::StringPiece& domain) { |
| 87 std::string ret; | 92 std::string ret; |
| 88 | 93 |
| 89 for (unsigned i = 0; i < domain.size() && domain[i]; i += domain[i] + 1) { | 94 for (unsigned i = 0; i < domain.size() && domain[i]; i += domain[i] + 1) { |
| 90 #if CHAR_MIN < 0 | 95 #if CHAR_MIN < 0 |
| 91 if (domain[i] < 0) | 96 if (domain[i] < 0) |
| 92 return std::string(); | 97 return std::string(); |
| 93 #endif | 98 #endif |
| 94 if (domain[i] > 63) | 99 if (domain[i] > 63) |
| 95 return std::string(); | 100 return std::string(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return DELTA_IDENTICAL; | 223 return DELTA_IDENTICAL; |
| 219 else if (same_size && !any_missing) | 224 else if (same_size && !any_missing) |
| 220 return DELTA_REORDERED; | 225 return DELTA_REORDERED; |
| 221 else if (any_match) | 226 else if (any_match) |
| 222 return DELTA_OVERLAP; | 227 return DELTA_OVERLAP; |
| 223 else | 228 else |
| 224 return DELTA_DISJOINT; | 229 return DELTA_DISJOINT; |
| 225 } | 230 } |
| 226 | 231 |
| 227 } // namespace net | 232 } // namespace net |
| OLD | NEW |