From: Francis Dupont Date: Tue, 12 May 2015 02:23:07 +0000 (+0200) Subject: [3824] #3824 patches X-Git-Tag: trac3919_base~4^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7697c53c441338748fd678e10c3b38384f379ef6;p=thirdparty%2Fkea.git [3824] #3824 patches --- diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index 80b1053432..f508bf3de4 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -12,6 +12,8 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. +#include + #include #include #include @@ -657,9 +659,8 @@ MasterLoader::MasterLoaderImpl::generateForIter(const std::string& str, continue; } - // 'it' can be equal to str.end() here, but it is handled - // correctly. - if (*it != '{') { + // The str.end() check is required. + if ((it == str.end()) || (*it != '{')) { // There is no modifier (between {}), so just copy the // passed number into the generated string. rstr += boost::str(boost::format("%d") % num); diff --git a/src/lib/dns/rdata/generic/detail/char_string.cc b/src/lib/dns/rdata/generic/detail/char_string.cc index 328fa7b406..702ba3072a 100644 --- a/src/lib/dns/rdata/generic/detail/char_string.cc +++ b/src/lib/dns/rdata/generic/detail/char_string.cc @@ -186,6 +186,15 @@ int compareCharStrings(const detail::CharString& self, const size_t self_len = self[0]; const size_t other_len = other[0]; const size_t cmp_len = std::min(self_len, other_len); + if (cmp_len == 0) { + if (self_len < other_len) { + return (-1); + } else if (self_len > other_len) { + return (1); + } else { + return (0); + } + } const int cmp = std::memcmp(&self[1], &other[1], cmp_len); if (cmp < 0) { return (-1); diff --git a/src/lib/dns/rdata/generic/dnskey_48.cc b/src/lib/dns/rdata/generic/dnskey_48.cc index 3ef6c72f90..8b93014717 100644 --- a/src/lib/dns/rdata/generic/dnskey_48.cc +++ b/src/lib/dns/rdata/generic/dnskey_48.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010, 2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -268,6 +268,9 @@ DNSKEY::compare(const Rdata& other) const { const size_t this_len = impl_->keydata_.size(); const size_t other_len = other_dnskey.impl_->keydata_.size(); const size_t cmplen = min(this_len, other_len); + if (cmplen == 0) { + return ((this_len == other_len) ? 0 : (this_len < other_len) ? -1 : 1); + } const int cmp = memcmp(&impl_->keydata_[0], &other_dnskey.impl_->keydata_[0], cmplen); if (cmp != 0) { diff --git a/src/lib/dns/rdata/generic/opt_41.cc b/src/lib/dns/rdata/generic/opt_41.cc index 6b292e9fa1..7ed28df100 100644 --- a/src/lib/dns/rdata/generic/opt_41.cc +++ b/src/lib/dns/rdata/generic/opt_41.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2013 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2013, 2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -211,7 +211,9 @@ OPT::appendPseudoRR(uint16_t code, const uint8_t* data, uint16_t length) { boost::shared_ptr > option_data(new std::vector(length)); - std::memcpy(&(*option_data)[0], data, length); + if (length != 0) { + std::memcpy(&(*option_data)[0], data, length); + } impl_->pseudo_rrs_.push_back(PseudoRR(code, option_data)); impl_->rdlength_ += length; } diff --git a/src/lib/dns/rdataclass.cc b/src/lib/dns/rdataclass.cc index 9e0390f781..5a2ceb1574 100644 --- a/src/lib/dns/rdataclass.cc +++ b/src/lib/dns/rdataclass.cc @@ -1855,6 +1855,9 @@ DNSKEY::compare(const Rdata& other) const { const size_t this_len = impl_->keydata_.size(); const size_t other_len = other_dnskey.impl_->keydata_.size(); const size_t cmplen = min(this_len, other_len); + if (cmplen == 0) { + return ((this_len == other_len) ? 0 : (this_len < other_len) ? -1 : 1); + } const int cmp = memcmp(&impl_->keydata_[0], &other_dnskey.impl_->keydata_[0], cmplen); if (cmp != 0) { @@ -3961,7 +3964,9 @@ OPT::appendPseudoRR(uint16_t code, const uint8_t* data, uint16_t length) { boost::shared_ptr > option_data(new std::vector(length)); - std::memcpy(&(*option_data)[0], data, length); + if (length != 0) { + std::memcpy(&(*option_data)[0], data, length); + } impl_->pseudo_rrs_.push_back(PseudoRR(code, option_data)); impl_->rdlength_ += length; }