2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 14:35:29 +00:00

[trac847] Don't increment invalid iterator

The problem was, it was increased after invalidating once before
checking the condition again. It is probably harmless, but according to
the letter not legal.
This commit is contained in:
Michal 'vorner' Vaner
2011-04-25 20:35:34 +02:00
parent e5cae84640
commit 0194e3a376

View File

@@ -1,4 +1,3 @@
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
// //
// Permission to use, copy, modify, and/or distribute this software for any // Permission to use, copy, modify, and/or distribute this software for any
@@ -50,7 +49,7 @@ ResponseScrubber::Category ResponseScrubber::addressCheck(
unsigned int unsigned int
ResponseScrubber::scrubSection(Message& message, ResponseScrubber::scrubSection(Message& message,
const vector<const Name*>& names, const vector<const Name*>& names,
const NameComparisonResult::NameRelation connection, const NameComparisonResult::NameRelation connection,
const Message::Section section) const Message::Section section)
{ {
unsigned int count = 0; // Count of RRsets removed unsigned int count = 0; // Count of RRsets removed
@@ -74,22 +73,23 @@ ResponseScrubber::scrubSection(Message& message,
// Start looking at the remaining entries in the section. // Start looking at the remaining entries in the section.
removed = false; removed = false;
for (; (i != message.endSection(section)) && (!removed); ++i) { for (; i != message.endSection(section); ++i) {
// Loop through the list of names given and see if any are in the // Loop through the list of names given and see if any are in the
// given relationship with the QNAME of this RRset // given relationship with the QNAME of this RRset
bool nomatch = true; bool nomatch = true;
for (vector<const Name*>::const_iterator n = names.begin(); for (vector<const Name*>::const_iterator n = names.begin();
((n != names.end()) && nomatch); ++n) { ((n != names.end())); ++n) {
NameComparisonResult result = (*i)->getName().compare(**n); NameComparisonResult result = (*i)->getName().compare(**n);
NameComparisonResult::NameRelation relationship = NameComparisonResult::NameRelation relationship =
result.getRelation(); result.getRelation();
if ((relationship == NameComparisonResult::EQUAL) || if ((relationship == NameComparisonResult::EQUAL) ||
(relationship == connection)) { (relationship == connection)) {
// RRset in the specified relationship, so a match has // RRset in the specified relationship, so a match has
// been found // been found
nomatch = false; nomatch = false;
break;
} }
} }
@@ -98,6 +98,7 @@ ResponseScrubber::scrubSection(Message& message,
message.removeRRset(section, i); message.removeRRset(section, i);
++count; // One more RRset removed ++count; // One more RRset removed
removed = true; // Something was removed removed = true; // Something was removed
break; // It invalidated the iterators, start again
} else { } else {
// There was a match so this is one more entry we can skip next // There was a match so this is one more entry we can skip next