Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of std::distance() in DNSName::isPartOf() #3989

Merged
merged 1 commit into from Jun 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions pdns/dnsname.cc
Expand Up @@ -200,8 +200,12 @@ bool DNSName::isPartOf(const DNSName& parent) const
return false;

// this is slightly complicated since we can't start from the end, since we can't see where a label begins/ends then
for(auto us=d_storage.cbegin(); us<d_storage.cend() && std::distance(us,d_storage.cend()) >= static_cast<unsigned int>(parent.d_storage.size()); us+=*us+1) {
if (std::distance(us,d_storage.cend()) == static_cast<unsigned int>(parent.d_storage.size())) {
for(auto us=d_storage.cbegin(); us<d_storage.cend(); us+=*us+1) {
auto distance = std::distance(us,d_storage.cend());
if (distance < 0 || static_cast<size_t>(distance) < parent.d_storage.size()) {
break;
}
if (static_cast<size_t>(distance) == parent.d_storage.size()) {
auto p = parent.d_storage.cbegin();
for(; us != d_storage.cend(); ++us, ++p) {
if(dns2_tolower(*p) != dns2_tolower(*us))
Expand Down