Browse Source

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

Francis Dupont 9 years ago
parent
commit
da7d3e0b2f

+ 2 - 3
src/lib/dns/master_loader.cc

@@ -657,9 +657,8 @@ MasterLoader::MasterLoaderImpl::generateForIter(const std::string& str,
               continue;
               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
               // There is no modifier (between {}), so just copy the
               // passed number into the generated string.
               // passed number into the generated string.
               rstr += boost::str(boost::format("%d") % num);
               rstr += boost::str(boost::format("%d") % num);

+ 10 - 1
src/lib/dns/rdata/generic/detail/char_string.cc

@@ -1,4 +1,4 @@
-// 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
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
 // 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 self_len = self[0];
     const size_t other_len = other[0];
     const size_t other_len = other[0];
     const size_t cmp_len = std::min(self_len, other_len);
     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);
     const int cmp = std::memcmp(&self[1], &other[1], cmp_len);
     if (cmp < 0) {
     if (cmp < 0) {
         return (-1);
         return (-1);

+ 4 - 1
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
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
 // 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 this_len = impl_->keydata_.size();
     const size_t other_len = other_dnskey.impl_->keydata_.size();
     const size_t other_len = other_dnskey.impl_->keydata_.size();
     const size_t cmplen = min(this_len, other_len);
     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],
     const int cmp = memcmp(&impl_->keydata_[0],
                            &other_dnskey.impl_->keydata_[0], cmplen);
                            &other_dnskey.impl_->keydata_[0], cmplen);
     if (cmp != 0) {
     if (cmp != 0) {

+ 4 - 2
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
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
 // 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> >
     boost::shared_ptr<std::vector<uint8_t> >
         option_data(new std::vector<uint8_t>(length));
         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_->pseudo_rrs_.push_back(PseudoRR(code, option_data));
     impl_->rdlength_ += length;
     impl_->rdlength_ += length;
 }
 }

+ 6 - 1
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 this_len = impl_->keydata_.size();
     const size_t other_len = other_dnskey.impl_->keydata_.size();
     const size_t other_len = other_dnskey.impl_->keydata_.size();
     const size_t cmplen = min(this_len, other_len);
     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],
     const int cmp = memcmp(&impl_->keydata_[0],
                            &other_dnskey.impl_->keydata_[0], cmplen);
                            &other_dnskey.impl_->keydata_[0], cmplen);
     if (cmp != 0) {
     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> >
     boost::shared_ptr<std::vector<uint8_t> >
         option_data(new std::vector<uint8_t>(length));
         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_->pseudo_rrs_.push_back(PseudoRR(code, option_data));
     impl_->rdlength_ += length;
     impl_->rdlength_ += length;
 }
 }