Commit da7d3e0b authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Merged trac3824 (small bugs in dns++ from VS)

parents ce0d4001 041f9682
......@@ -657,9 +657,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);
......
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012, 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
......@@ -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);
......
// 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) {
......
// 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<std::vector<uint8_t> >
option_data(new std::vector<uint8_t>(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;
}
......
......@@ -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<std::vector<uint8_t> >
option_data(new std::vector<uint8_t>(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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment