BIND 10 trac2749, updated. c7aeb4bec30cf6373e77216058174d6d35850dde [2749] Update rest of tree to use the modified io_utilities.h API

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jan 10 04:36:14 UTC 2014


The branch, trac2749 has been updated
       via  c7aeb4bec30cf6373e77216058174d6d35850dde (commit)
      from  d58433297eb07de97a7713dab8fbedbe46b1be3c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c7aeb4bec30cf6373e77216058174d6d35850dde
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Jan 10 09:31:50 2014 +0530

    [2749] Update rest of tree to use the modified io_utilities.h API

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/dhcp6_srv.cc                         |   15 ++++++++-------
 src/lib/asiodns/io_fetch.cc                        |    2 +-
 src/lib/asiodns/tests/io_fetch_unittest.cc         |    7 +++++--
 src/lib/asiolink/tcp_socket.h                      |    2 +-
 src/lib/asiolink/tests/tcp_socket_unittest.cc      |    6 +++---
 src/lib/asiolink/tests/udp_socket_unittest.cc      |    2 +-
 src/lib/dhcp/libdhcp++.cc                          |    8 ++++----
 src/lib/dhcp/option.cc                             |    8 ++++----
 src/lib/dhcp/option4_addrlst.cc                    |    2 +-
 src/lib/dhcp/option6_ia.cc                         |    6 +++---
 src/lib/dhcp/option6_iaaddr.cc                     |    4 ++--
 src/lib/dhcp/option6_iaprefix.cc                   |    4 ++--
 src/lib/dhcp/option_data_types.h                   |    8 ++++----
 src/lib/dhcp/option_int.h                          |    6 ++++--
 src/lib/dhcp/option_int_array.h                    |    6 ++++--
 src/lib/dhcp/option_vendor.cc                      |    2 +-
 .../resolve/tests/recursive_query_unittest_2.cc    |    3 ++-
 .../resolve/tests/recursive_query_unittest_3.cc    |    3 ++-
 18 files changed, 52 insertions(+), 42 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 506eefd..7a3b804 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -604,9 +604,10 @@ Dhcpv6Srv::generateServerID() {
         seconds -= DUID_TIME_EPOCH;
 
         OptionBuffer srvid(8 + iface->getMacLen());
-        writeUint16(DUID::DUID_LLT, &srvid[0]);
-        writeUint16(HWTYPE_ETHERNET, &srvid[2]);
-        writeUint32(static_cast<uint32_t>(seconds), &srvid[4]);
+        writeUint16(DUID::DUID_LLT, &srvid[0], srvid.size());
+        writeUint16(HWTYPE_ETHERNET, &srvid[2], srvid.size() - 2);
+        writeUint32(static_cast<uint32_t>(seconds), &srvid[4],
+                    srvid.size() - 4);
         memcpy(&srvid[0] + 8, iface->getMac(), iface->getMacLen());
 
         serverid_ = OptionPtr(new Option(Option::V6, D6O_SERVERID,
@@ -620,8 +621,8 @@ Dhcpv6Srv::generateServerID() {
     // See Section 9.3 of RFC3315 for details.
 
     OptionBuffer srvid(12);
-    writeUint16(DUID::DUID_EN, &srvid[0]);
-    writeUint32(ENTERPRISE_ID_ISC, &srvid[2]);
+    writeUint16(DUID::DUID_EN, &srvid[0], srvid.size());
+    writeUint32(ENTERPRISE_ID_ISC, &srvid[2], srvid.size() - 2);
 
     // Length of the identifier is company specific. I hereby declare
     // ISC "standard" of 6 bytes long pseudo-random numbers.
@@ -2344,10 +2345,10 @@ Dhcpv6Srv::unpackOptions(const OptionBuffer& buf,
     // The buffer being read comprises a set of options, each starting with
     // a two-byte type code and a two-byte length field.
     while (offset + 4 <= length) {
-        uint16_t opt_type = isc::util::readUint16(&buf[offset]);
+        uint16_t opt_type = isc::util::readUint16(&buf[offset], 2);
         offset += 2;
 
-        uint16_t opt_len = isc::util::readUint16(&buf[offset]);
+        uint16_t opt_len = isc::util::readUint16(&buf[offset], 2);
         offset += 2;
 
         if (offset + opt_len > length) {
diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc
index a09d8df..aef7c57 100644
--- a/src/lib/asiodns/io_fetch.cc
+++ b/src/lib/asiodns/io_fetch.cc
@@ -162,7 +162,7 @@ struct IOFetchData {
     // we sent.
     bool responseOK() {
         return (*remote_snd == *remote_rcv && cumulative >= 2 &&
-                readUint16(received->getData()) == qid);
+                readUint16(received->getData(), received->getLength()) == qid);
     }
 };
 
diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc
index acb184c..1357a7b 100644
--- a/src/lib/asiodns/tests/io_fetch_unittest.cc
+++ b/src/lib/asiodns/tests/io_fetch_unittest.cc
@@ -280,7 +280,7 @@ public:
         cumulative_ += length;
         bool complete = false;
         if (cumulative_ > 2) {
-            uint16_t dns_length = readUint16(receive_buffer_);
+            uint16_t dns_length = readUint16(receive_buffer_, sizeof (receive_buffer_));
             complete = ((dns_length + 2) == cumulative_);
         }
 
@@ -310,7 +310,10 @@ public:
         send_buffer_.clear();
         send_buffer_.push_back(0);
         send_buffer_.push_back(0);
-        writeUint16(return_data_.size(), &send_buffer_[0]);
+        // send_buffer_.capacity() seems more logical below, but the
+        // code above fills in the first two bytes and size() becomes 2
+        // (sizeof uint16_t).
+        writeUint16(return_data_.size(), &send_buffer_[0], send_buffer_.size());
         copy(return_data_.begin(), return_data_.end(), back_inserter(send_buffer_));
         if (return_data_.size() >= 2) {
             send_buffer_[2] = qid_0;
diff --git a/src/lib/asiolink/tcp_socket.h b/src/lib/asiolink/tcp_socket.h
index 7df4a80..18eca95 100644
--- a/src/lib/asiolink/tcp_socket.h
+++ b/src/lib/asiolink/tcp_socket.h
@@ -358,7 +358,7 @@ TCPSocket<C>::processReceivedData(const void* staging, size_t length,
         }
 
         // Have enough data to interpret the packet count, so do so now.
-        expected = isc::util::readUint16(data);
+        expected = isc::util::readUint16(data, cumulative);
 
         // We have two bytes less of data to process.  Point to the start of the
         // data and adjust the packet size.  Note that at this point,
diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc
index 9de366c..8683318 100644
--- a/src/lib/asiolink/tests/tcp_socket_unittest.cc
+++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc
@@ -227,7 +227,7 @@ serverRead(tcp::socket& socket, TCPCallback& server_cb) {
         // If we have read at least two bytes, we can work out how much we
         // should be reading.
         if (server_cb.cumulative() >= 2) {
-           server_cb.expected() = readUint16(server_cb.data());
+            server_cb.expected() = readUint16(server_cb.data(), server_cb.length());
             if ((server_cb.expected() + 2) == server_cb.cumulative()) {
 
                 // Amount of data read from socket equals the size of the
@@ -261,7 +261,7 @@ TEST(TCPSocket, processReceivedData) {
     }
 
     // Check that the method will handle various receive sizes.
-    writeUint16(PACKET_SIZE, inbuff);
+    writeUint16(PACKET_SIZE, inbuff, sizeof (inbuff));
 
     cumulative = 0;
     offset = 0;
@@ -408,7 +408,7 @@ TEST(TCPSocket, SequenceTest) {
     server_cb.length() = 0;
     server_cb.cumulative() = 0;
 
-    writeUint16(sizeof(INBOUND_DATA), server_cb.data());
+    writeUint16(sizeof(INBOUND_DATA), server_cb.data(), 2);
     copy(INBOUND_DATA, (INBOUND_DATA + sizeof(INBOUND_DATA) - 1),
         (server_cb.data() + 2));
     server_socket.async_send(asio::buffer(server_cb.data(),
diff --git a/src/lib/asiolink/tests/udp_socket_unittest.cc b/src/lib/asiolink/tests/udp_socket_unittest.cc
index 3d91874..4a81d73 100644
--- a/src/lib/asiolink/tests/udp_socket_unittest.cc
+++ b/src/lib/asiolink/tests/udp_socket_unittest.cc
@@ -188,7 +188,7 @@ TEST(UDPSocket, processReceivedData) {
     // two bytes of the buffer.
     uint16_t count = 0;
     for (uint32_t i = 0; i < (2 << 16); ++i, ++count) {
-        writeUint16(count, inbuff);
+        writeUint16(count, inbuff, sizeof (inbuff));
 
         // Set some random values
         cumulative = 5;
diff --git a/src/lib/dhcp/libdhcp++.cc b/src/lib/dhcp/libdhcp++.cc
index 4577c64..84fe868 100644
--- a/src/lib/dhcp/libdhcp++.cc
+++ b/src/lib/dhcp/libdhcp++.cc
@@ -223,10 +223,10 @@ size_t LibDHCP::unpackOptions6(const OptionBuffer& buf,
     // The buffer being read comprises a set of options, each starting with
     // a two-byte type code and a two-byte length field.
     while (offset + 4 <= length) {
-        uint16_t opt_type = isc::util::readUint16(&buf[offset]);
+        uint16_t opt_type = isc::util::readUint16(&buf[offset], 2);
         offset += 2;
 
-        uint16_t opt_len = isc::util::readUint16(&buf[offset]);
+        uint16_t opt_len = isc::util::readUint16(&buf[offset], 2);
         offset += 2;
 
         if (offset + opt_len > length) {
@@ -405,10 +405,10 @@ size_t LibDHCP::unpackVendorOptions6(const uint32_t vendor_id,
     // The buffer being read comprises a set of options, each starting with
     // a two-byte type code and a two-byte length field.
     while (offset + 4 <= length) {
-        uint16_t opt_type = isc::util::readUint16(&buf[offset]);
+        uint16_t opt_type = isc::util::readUint16(&buf[offset], 2);
         offset += 2;
 
-        uint16_t opt_len = isc::util::readUint16(&buf[offset]);
+        uint16_t opt_len = isc::util::readUint16(&buf[offset], 2);
         offset += 2;
 
         if (offset + opt_len > length) {
diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc
index f5ab75e..b6c157b 100644
--- a/src/lib/dhcp/option.cc
+++ b/src/lib/dhcp/option.cc
@@ -255,7 +255,7 @@ uint16_t Option::getUint16() {
                   << " that has size " << data_.size());
     }
 
-    return ( readUint16(&data_[0]) );
+    return (readUint16(&data_[0], data_.size()));
 }
 
 uint32_t Option::getUint32() {
@@ -263,7 +263,7 @@ uint32_t Option::getUint32() {
         isc_throw(OutOfRange, "Attempt to read uint32 from option " << type_
                   << " that has size " << data_.size());
     }
-    return ( readUint32(&data_[0]) );
+    return (readUint32(&data_[0], data_.size()));
 }
 
 void Option::setUint8(uint8_t value) {
@@ -273,12 +273,12 @@ void Option::setUint8(uint8_t value) {
 
 void Option::setUint16(uint16_t value) {
   data_.resize(2);
-  writeUint16(value, &data_[0]);
+  writeUint16(value, &data_[0], data_.size());
 }
 
 void Option::setUint32(uint32_t value) {
   data_.resize(4);
-  writeUint32(value, &data_[0]);
+  writeUint32(value, &data_[0], data_.size());
 }
 
 bool Option::equal(const OptionPtr& other) const {
diff --git a/src/lib/dhcp/option4_addrlst.cc b/src/lib/dhcp/option4_addrlst.cc
index 436d07d..223da16 100644
--- a/src/lib/dhcp/option4_addrlst.cc
+++ b/src/lib/dhcp/option4_addrlst.cc
@@ -53,7 +53,7 @@ Option4AddrLst::Option4AddrLst(uint8_t type, OptionBufferConstIter first,
 
     while (first != last) {
         const uint8_t* ptr = &(*first);
-        addAddress(IOAddress(readUint32(ptr)));
+        addAddress(IOAddress(readUint32(ptr, distance(first, last))));
         first += V4ADDRESS_LEN;
     }
 }
diff --git a/src/lib/dhcp/option6_ia.cc b/src/lib/dhcp/option6_ia.cc
index 825a5bf..a5751dd 100644
--- a/src/lib/dhcp/option6_ia.cc
+++ b/src/lib/dhcp/option6_ia.cc
@@ -72,12 +72,12 @@ void Option6IA::unpack(OptionBufferConstIter begin,
     if (distance(begin, end) < OPTION6_IA_LEN) {
         isc_throw(OutOfRange, "Option " << type_ << " truncated");
     }
-    iaid_ = readUint32( &(*begin) );
+    iaid_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
-    t1_ = readUint32( &(*begin) );
+    t1_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
 
-    t2_ = readUint32( &(*begin) );
+    t2_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
 
     unpackOptions(OptionBuffer(begin, end));
diff --git a/src/lib/dhcp/option6_iaaddr.cc b/src/lib/dhcp/option6_iaaddr.cc
index 39efa61..56ae431 100644
--- a/src/lib/dhcp/option6_iaaddr.cc
+++ b/src/lib/dhcp/option6_iaaddr.cc
@@ -79,10 +79,10 @@ void Option6IAAddr::unpack(OptionBuffer::const_iterator begin,
     addr_ = IOAddress::fromBytes(AF_INET6, &(*begin));
     begin += V6ADDRESS_LEN;
 
-    preferred_ = readUint32( &(*begin) );
+    preferred_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
 
-    valid_ = readUint32( &(*begin) );
+    valid_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
 
     unpackOptions(OptionBuffer(begin, end));
diff --git a/src/lib/dhcp/option6_iaprefix.cc b/src/lib/dhcp/option6_iaprefix.cc
index a7776d7..c791bf1 100644
--- a/src/lib/dhcp/option6_iaprefix.cc
+++ b/src/lib/dhcp/option6_iaprefix.cc
@@ -76,10 +76,10 @@ void Option6IAPrefix::unpack(OptionBuffer::const_iterator begin,
         isc_throw(OutOfRange, "Option " << type_ << " truncated");
     }
 
-    preferred_ = readUint32( &(*begin) );
+    preferred_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
 
-    valid_ = readUint32( &(*begin) );
+    valid_ = readUint32(&(*begin), distance(begin, end));
     begin += sizeof(uint32_t);
 
     prefix_len_ = *begin;
diff --git a/src/lib/dhcp/option_data_types.h b/src/lib/dhcp/option_data_types.h
index d9d8a52..fb4d101 100644
--- a/src/lib/dhcp/option_data_types.h
+++ b/src/lib/dhcp/option_data_types.h
@@ -298,12 +298,12 @@ public:
         case 2:
             // Calling readUint16 works either for unsigned
             // or signed types.
-            value = isc::util::readUint16(&(*buf.begin()));
+            value = isc::util::readUint16(&(*buf.begin()), buf.size());
             break;
         case 4:
             // Calling readUint32 works either for unsigned
             // or signed types.
-            value = isc::util::readUint32(&(*buf.begin()));
+            value = isc::util::readUint32(&(*buf.begin()), buf.size());
             break;
         default:
             // This should not happen because we made checks on data types
@@ -331,11 +331,11 @@ public:
             break;
         case 2:
             buf.resize(buf.size() + 2);
-            isc::util::writeUint16(static_cast<uint16_t>(value), &buf[buf.size() - 2]);
+            isc::util::writeUint16(static_cast<uint16_t>(value), &buf[buf.size() - 2], 2);
             break;
         case 4:
             buf.resize(buf.size() + 4);
-            isc::util::writeUint32(static_cast<uint32_t>(value), &buf[buf.size() - 4]);
+            isc::util::writeUint32(static_cast<uint32_t>(value), &buf[buf.size() - 4], 4);
             break;
         default:
             // The cases above cover whole range of possible data lengths because
diff --git a/src/lib/dhcp/option_int.h b/src/lib/dhcp/option_int.h
index cbdbcb0..f11b4eb 100644
--- a/src/lib/dhcp/option_int.h
+++ b/src/lib/dhcp/option_int.h
@@ -142,10 +142,12 @@ public:
             value_ = *begin;
             break;
         case 2:
-            value_ = isc::util::readUint16(&(*begin));
+            value_ = isc::util::readUint16(&(*begin),
+                                           std::distance(begin, end));
             break;
         case 4:
-            value_ = isc::util::readUint32(&(*begin));
+            value_ = isc::util::readUint32(&(*begin),
+                                           std::distance(begin, end));
             break;
         default:
             isc_throw(dhcp::InvalidDataType, "non-integer type");
diff --git a/src/lib/dhcp/option_int_array.h b/src/lib/dhcp/option_int_array.h
index e0e9356..62e121b 100644
--- a/src/lib/dhcp/option_int_array.h
+++ b/src/lib/dhcp/option_int_array.h
@@ -201,10 +201,12 @@ public:
                 values_.push_back(*begin);
                 break;
             case 2:
-                values_.push_back(isc::util::readUint16(&(*begin)));
+                values_.push_back(isc::util::readUint16(&(*begin),
+                                      std::distance(begin, end)));
                 break;
             case 4:
-                values_.push_back(isc::util::readUint32(&(*begin)));
+                values_.push_back(isc::util::readUint32(&(*begin),
+                                      std::distance(begin, end)));
                 break;
             default:
                 isc_throw(dhcp::InvalidDataType, "non-integer type");
diff --git a/src/lib/dhcp/option_vendor.cc b/src/lib/dhcp/option_vendor.cc
index 878b534..0d5c550 100644
--- a/src/lib/dhcp/option_vendor.cc
+++ b/src/lib/dhcp/option_vendor.cc
@@ -54,7 +54,7 @@ void OptionVendor::unpack(OptionBufferConstIter begin,
                   << ", length=" << distance(begin, end));
     }
 
-    vendor_id_ = isc::util::readUint32(&(*begin));
+    vendor_id_ = isc::util::readUint32(&(*begin), distance(begin, end));
 
     OptionBuffer vendor_buffer(begin +4, end);
 
diff --git a/src/lib/resolve/tests/recursive_query_unittest_2.cc b/src/lib/resolve/tests/recursive_query_unittest_2.cc
index d6019d0..5557e20 100644
--- a/src/lib/resolve/tests/recursive_query_unittest_2.cc
+++ b/src/lib/resolve/tests/recursive_query_unittest_2.cc
@@ -462,7 +462,8 @@ public:
         tcp_cumulative_ += length;
         bool complete = false;
         if (tcp_cumulative_ > 2) {
-            uint16_t dns_length = readUint16(tcp_receive_buffer_);
+            uint16_t dns_length = readUint16(tcp_receive_buffer_,
+                                             sizeof (tcp_receive_buffer_));
             complete = ((dns_length + 2) == tcp_cumulative_);
         }
 
diff --git a/src/lib/resolve/tests/recursive_query_unittest_3.cc b/src/lib/resolve/tests/recursive_query_unittest_3.cc
index 7803b88..1049bf2 100644
--- a/src/lib/resolve/tests/recursive_query_unittest_3.cc
+++ b/src/lib/resolve/tests/recursive_query_unittest_3.cc
@@ -336,7 +336,8 @@ public:
         tcp_cumulative_ += length;
         bool complete = false;
         if (tcp_cumulative_ > 2) {
-            uint16_t dns_length = readUint16(tcp_receive_buffer_);
+            uint16_t dns_length = readUint16(tcp_receive_buffer_,
+                                             sizeof (tcp_receive_buffer_));
             complete = ((dns_length + 2) == tcp_cumulative_);
         }
 



More information about the bind10-changes mailing list