|
@@ -505,7 +505,9 @@ RdataEncoder::start(RRClass rrclass, RRType rrtype, const void* old_data,
|
|
|
// keep them in rdatas_ and rrsigs_ so we can detect and ignore duplicate
|
|
|
// data with the existing one later. We'll also figure out the lengths
|
|
|
// of the RDATA and RRSIG part of the data by iterating over the data
|
|
|
- // fields.
|
|
|
+ // fields. Note that the given old_data shouldn't contain duplicate
|
|
|
+ // Rdata or RRSIG as they should have been generated by this own class,
|
|
|
+ // which ensures that condition; if this assumption doesn't hold, we throw.
|
|
|
size_t total_len = 0;
|
|
|
RdataReader reader(rrclass, rrtype, old_data, old_rdata_count,
|
|
|
old_sig_count,
|
|
@@ -516,8 +518,11 @@ RdataEncoder::start(RRClass rrclass, RRType rrtype, const void* old_data,
|
|
|
while (reader.iterateRdata()) {
|
|
|
util::InputBuffer ibuffer(impl_->olddata_buffer_.getData(),
|
|
|
impl_->olddata_buffer_.getLength());
|
|
|
- impl_->rdatas_.insert(createRdata(rrtype, rrclass, ibuffer,
|
|
|
- impl_->olddata_buffer_.getLength()));
|
|
|
+ if (!impl_->rdatas_.insert(
|
|
|
+ createRdata(rrtype, rrclass, ibuffer,
|
|
|
+ impl_->olddata_buffer_.getLength())).second) {
|
|
|
+ isc_throw(Unexpected, "duplicate RDATA found in merging RdataSet");
|
|
|
+ }
|
|
|
impl_->olddata_buffer_.clear();
|
|
|
}
|
|
|
impl_->old_data_len_ = total_len;
|
|
@@ -526,8 +531,11 @@ RdataEncoder::start(RRClass rrclass, RRType rrtype, const void* old_data,
|
|
|
while (reader.iterateSingleSig()) {
|
|
|
util::InputBuffer ibuffer(impl_->olddata_buffer_.getData(),
|
|
|
impl_->olddata_buffer_.getLength());
|
|
|
- impl_->rrsigs_.insert(createRdata(RRType::RRSIG(), rrclass, ibuffer,
|
|
|
- impl_->olddata_buffer_.getLength()));
|
|
|
+ if (!impl_->rrsigs_.insert(
|
|
|
+ createRdata(RRType::RRSIG(), rrclass, ibuffer,
|
|
|
+ impl_->olddata_buffer_.getLength())).second) {
|
|
|
+ isc_throw(Unexpected, "duplicate RRSIG found in merging RdataSet");
|
|
|
+ }
|
|
|
impl_->olddata_buffer_.clear();
|
|
|
}
|
|
|
impl_->old_sig_len_ = total_len;
|