]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4691] always use buffer size on send
authorRazvan Becheriu <razvan@isc.org>
Mon, 3 Aug 2026 12:39:13 +0000 (15:39 +0300)
committerRazvan Becheriu <razvan@isc.org>
Tue, 4 Aug 2026 05:13:32 +0000 (05:13 +0000)
ChangeLog
src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc
src/hooks/dhcp/lease_query/lease_query_impl6.cc
src/hooks/dhcp/mysql/mysql_host_data_source.cc
src/hooks/dhcp/mysql/mysql_lease_mgr.cc
src/lib/mysql/mysql_connection.h

index c60cdbb9edc22f47c0a184bdaf9c81edb9a4c015..7a80eb4c6278b0de325efcf1f6ce6bc3ff4dda51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,14 @@
 
 Kea 3.3.0 (development) released on July 29, 2026
 
+2524.  [func]          razvan
+       Added support for unlimited encapsulation levels in evaluated
+       expressions: option[code0].option[code1]...option[codeX],
+       relay4[code0].option[code1]...option[codeX],
+       relay6[nest].option[code0].option[code1]...option[codeX] and
+       vendor[ent-id].option[code0].option[code1]...option[codeX].
+       (Gitlab #4146)
+
 2523.  [func]          fdupont
        RADIUS accounting now ignores DHCPv4 lease reuses.
        (Gitlab #4544)
index c9189f5aebe71ed0bdd19b0c07f59f79c207c0d9..ee07e6ca62d1a455aa52b61f72ad32e8b9f8aee4 100644 (file)
@@ -2072,6 +2072,7 @@ TEST_F(FlexOptionLogTest, noWarning) {
     ElementPtr code = Element::create(DHO_HOST_NAME);
     option->set("code", code);
     option->set("client-class", Element::create(string("foobar")));
+
     EXPECT_NO_THROW(impl_->testConfigure(options));
     EXPECT_TRUE(impl_->getErrMsg().empty()) << impl_->getErrMsg();
 
@@ -2091,6 +2092,7 @@ TEST_F(FlexOptionLogTest, classWarning) {
     option->set("client-class", Element::create(string("foobar")));
     ElementPtr dest = Element::create(string("query"));
     option->set("destination", dest);
+
     EXPECT_NO_THROW(impl_->testConfigure(options));
     EXPECT_TRUE(impl_->getErrMsg().empty()) << impl_->getErrMsg();
 
@@ -2112,6 +2114,7 @@ TEST_F(FlexOptionLogTest, memberWarning) {
     option->set("code", code);
     ElementPtr dest = Element::create(string("query"));
     option->set("destination", dest);
+
     EXPECT_NO_THROW(impl_->testConfigure(options));
     EXPECT_TRUE(impl_->getErrMsg().empty()) << impl_->getErrMsg();
 
index 4ecb98e51bdf72836df704e9ea740dc0c40c5f5b..237c5ab4d78dfccf5f51becfe75c7b76d685901c 100644 (file)
@@ -952,7 +952,7 @@ LeaseQueryImpl6::makeRelayOption(const Lease6& lease) {
         buffer_out.writeData(&(relay->linkaddr_.toBytes()[0]),
                              isc::asiolink::V6ADDRESS_LEN);
         buffer_out.writeData(&relay->peeraddr_.toBytes()[0],
-                              isc::asiolink::V6ADDRESS_LEN);
+                             isc::asiolink::V6ADDRESS_LEN);
 
         // Store every option in this relay's scope.
         for (auto const& opt : relay->options_) {
index dfc7a08c20c0a8b631cf0a107db2ce10d220889f..36c2861e6c3ba5c7b0cdc5855315817dbf919122 100644 (file)
@@ -337,7 +337,7 @@ public:
 
             // hostname : VARCHAR(255) NULL
             strncpy(hostname_, host->getHostname().c_str(), HOSTNAME_MAX_LEN - 1);
-            hostname_length_ = host->getHostname().length();
+            hostname_length_ = std::min(host->getHostname().length(), HOSTNAME_MAX_LEN - 1);
             bind_[6].buffer_type = MYSQL_TYPE_STRING;
             bind_[6].buffer = reinterpret_cast<char*>(hostname_);
             bind_[6].buffer_length = hostname_length_;
@@ -348,7 +348,7 @@ public:
             string classes4_txt = host->getClientClasses4().toText(",");
             strncpy(dhcp4_client_classes_, classes4_txt.c_str(), CLIENT_CLASSES_MAX_LEN - 1);
             bind_[7].buffer = dhcp4_client_classes_;
-            bind_[7].buffer_length = classes4_txt.length();
+            bind_[7].buffer_length = std::min(classes4_txt.length(), CLIENT_CLASSES_MAX_LEN - 1);
 
             // dhcp6_client_classes : VARCHAR(255) NULL
             bind_[8].buffer_type = MYSQL_TYPE_STRING;
@@ -356,7 +356,7 @@ public:
             string classes6_txt = host->getClientClasses6().toText(",");
             strncpy(dhcp6_client_classes_, classes6_txt.c_str(), CLIENT_CLASSES_MAX_LEN - 1);
             bind_[8].buffer = dhcp6_client_classes_;
-            bind_[8].buffer_length = classes6_txt.length();
+            bind_[8].buffer_length = std::min(classes6_txt.length(), CLIENT_CLASSES_MAX_LEN - 1);
 
             // user_context : TEXT NULL
             ConstElementPtr ctx = host->getContext();
@@ -365,7 +365,7 @@ public:
                 string ctx_txt = ctx->str();
                 strncpy(user_context_, ctx_txt.c_str(), USER_CONTEXT_MAX_LEN - 1);
                 bind_[9].buffer = user_context_;
-                bind_[9].buffer_length = ctx_txt.length();
+                bind_[9].buffer_length = std::min(ctx_txt.length(), USER_CONTEXT_MAX_LEN - 1);
             } else {
                 bind_[9].buffer_type = MYSQL_TYPE_NULL;
             }
@@ -386,7 +386,8 @@ public:
             strncpy(dhcp4_server_hostname_, server_hostname.c_str(),
                     SERVER_HOSTNAME_MAX_LEN - 1);
             bind_[11].buffer = dhcp4_server_hostname_;
-            bind_[11].buffer_length = server_hostname.length();
+            bind_[11].buffer_length = std::min(server_hostname.length(),
+                                               SERVER_HOSTNAME_MAX_LEN - 1);
 
             // dhcp4_boot_file_name
             bind_[12].buffer_type = MYSQL_TYPE_STRING;
@@ -394,7 +395,8 @@ public:
             strncpy(dhcp4_boot_file_name_, boot_file_name.c_str(),
                     BOOT_FILE_NAME_MAX_LEN - 1);
             bind_[12].buffer = dhcp4_boot_file_name_;
-            bind_[12].buffer_length = boot_file_name.length();
+            bind_[12].buffer_length = std::min(boot_file_name.length(),
+                                               BOOT_FILE_NAME_MAX_LEN - 1);
 
             // auth key
             bind_[13].buffer_type = MYSQL_TYPE_STRING;
@@ -402,7 +404,7 @@ public:
             std::strncpy(auth_key_, auth_key.c_str(), TEXT_AUTH_KEY_LEN - 1);
             auth_key_null_ = auth_key.empty() ? MLM_TRUE : MLM_FALSE;
             bind_[13].buffer = auth_key_;
-            bind_[13].buffer_length = auth_key.length();
+            bind_[13].buffer_length = std::min(auth_key.length(), TEXT_AUTH_KEY_LEN - 1);
 
         } catch (const std::exception& ex) {
             isc_throw(DbOperationError,
@@ -1808,7 +1810,7 @@ public:
             addr6_length_ = isc::asiolink::V6ADDRESS_LEN;
             bind_[0].buffer_type = MYSQL_TYPE_BLOB;
             bind_[0].buffer = reinterpret_cast<char*>(&addr6_[0]);
-            bind_[0].buffer_length = isc::asiolink::V6ADDRESS_LEN;
+            bind_[0].buffer_length = addr6_length_;
             bind_[0].length = &addr6_length_;
 
             // prefix_len tinyint
@@ -2033,7 +2035,7 @@ public:
             bind_[6].buffer = reinterpret_cast<char*>(&cancelled_);
             bind_[6].is_unsigned = MLM_TRUE;
 
-            // user_context: TEST NULL,
+            // user_context: TEXT NULL,
             ConstElementPtr ctx = opt_desc.getContext();
             if (ctx) {
                 user_context_ = ctx->str();
@@ -3506,7 +3508,7 @@ MySqlHostDataSource::del(const SubnetID& subnet_id,
     unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[1].buffer_type = MYSQL_TYPE_BLOB;
     inbind[1].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[1].buffer_length = isc::asiolink::V6ADDRESS_LEN;
+    inbind[1].buffer_length = addr6_length;
     inbind[1].length = &addr6_length;
 
     return (impl_->delStatement(ctx, MySqlHostDataSourceImpl::DEL_HOST_ADDR6, inbind));
@@ -3615,7 +3617,7 @@ MySqlHostDataSource::getAll(const Host::IdentifierType& identifier_type,
     // Identifier value.
     std::vector<char> identifier_vec(identifier_begin,
                                      identifier_begin + identifier_len);
-    unsigned long int length = identifier_vec.size();
+    unsigned long length = identifier_vec.size();
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = &identifier_vec[0];
     inbind[0].buffer_length = length;
@@ -3681,11 +3683,12 @@ MySqlHostDataSource::getAllbyHostname(const std::string& hostname) const {
     memset(inbind, 0, sizeof(inbind));
 
     // Hostname
-    char hostname_[HOSTNAME_MAX_LEN];
-    strncpy(hostname_, hostname.c_str(), HOSTNAME_MAX_LEN - 1);
-    unsigned long length = hostname.length();
+    char hostname_c[HOSTNAME_MAX_LEN];
+    memset(hostname_c, 0, sizeof(hostname_c));
+    strncpy(hostname_c, hostname.c_str(), HOSTNAME_MAX_LEN - 1);
+    unsigned long length = std::min(hostname.length(), HOSTNAME_MAX_LEN - 1);
     inbind[0].buffer_type = MYSQL_TYPE_STRING;
-    inbind[0].buffer = reinterpret_cast<char*>(hostname_);
+    inbind[0].buffer = reinterpret_cast<char*>(hostname_c);
     inbind[0].buffer_length = length;
     inbind[0].length = &length;
 
@@ -3708,11 +3711,12 @@ MySqlHostDataSource::getAllbyHostname4(const std::string& hostname,
     memset(inbind, 0, sizeof(inbind));
 
     // Hostname
-    char hostname_[HOSTNAME_MAX_LEN];
-    strncpy(hostname_, hostname.c_str(), HOSTNAME_MAX_LEN - 1);
-    unsigned long length = hostname.length();
+    char hostname_c[HOSTNAME_MAX_LEN];
+    memset(hostname_c, 0, sizeof(hostname_c));
+    strncpy(hostname_c, hostname.c_str(), HOSTNAME_MAX_LEN - 1);
+    unsigned long length = std::min(hostname.length(), HOSTNAME_MAX_LEN - 1);
     inbind[0].buffer_type = MYSQL_TYPE_STRING;
-    inbind[0].buffer = reinterpret_cast<char*>(hostname_);
+    inbind[0].buffer = reinterpret_cast<char*>(hostname_c);
     inbind[0].buffer_length = length;
     inbind[0].length = &length;
 
@@ -3741,11 +3745,12 @@ MySqlHostDataSource::getAllbyHostname6(const std::string& hostname,
     memset(inbind, 0, sizeof(inbind));
 
     // Hostname
-    char hostname_[HOSTNAME_MAX_LEN];
-    strncpy(hostname_, hostname.c_str(), HOSTNAME_MAX_LEN - 1);
-    unsigned long length = hostname.length();
+    char hostname_c[HOSTNAME_MAX_LEN];
+    memset(hostname_c, 0, sizeof(hostname_c));
+    strncpy(hostname_c, hostname.c_str(), HOSTNAME_MAX_LEN - 1);
+    unsigned long length = std::min(hostname.length(), HOSTNAME_MAX_LEN - 1);
     inbind[0].buffer_type = MYSQL_TYPE_STRING;
-    inbind[0].buffer = reinterpret_cast<char*>(hostname_);
+    inbind[0].buffer = reinterpret_cast<char*>(hostname_c);
     inbind[0].buffer_length = length;
     inbind[0].length = &length;
 
@@ -4044,7 +4049,7 @@ MySqlHostDataSource::get6(const asiolink::IOAddress& prefix,
     unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[0].buffer_length = isc::asiolink::V6ADDRESS_LEN;
+    inbind[0].buffer_length = addr6_length;
     inbind[0].length = &addr6_length;
 
     uint8_t tmp = prefix_len;
@@ -4095,7 +4100,7 @@ MySqlHostDataSource::get6(const SubnetID& subnet_id,
     unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[1].buffer_type = MYSQL_TYPE_BLOB;
     inbind[1].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[1].buffer_length = isc::asiolink::V6ADDRESS_LEN;
+    inbind[1].buffer_length = addr6_length;
     inbind[1].length = &addr6_length;
 
     ConstHostCollection collection;
@@ -4141,7 +4146,7 @@ MySqlHostDataSource::getAll6(const SubnetID& subnet_id,
     unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[1].buffer_type = MYSQL_TYPE_BLOB;
     inbind[1].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[1].buffer_length = isc::asiolink::V6ADDRESS_LEN;
+    inbind[1].buffer_length = addr6_length;
     inbind[1].length = &addr6_length;
 
     ConstHostCollection collection;
@@ -4174,7 +4179,7 @@ MySqlHostDataSource::getAll6(const IOAddress& address) const {
     unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[0].buffer_length = isc::asiolink::V6ADDRESS_LEN;
+    inbind[0].buffer_length = addr6_length;
     inbind[0].length = &addr6_length;
 
     ConstHostCollection collection;
index 3d94a2cf3520cae1db5be09056c7b2068f9d4ea2..b4346dc01a7b4fb230e9d18a56918a654606594c 100644 (file)
@@ -995,7 +995,7 @@ public:
                 std::string ctx_txt = ctx->str();
                 strncpy(user_context_, ctx_txt.c_str(), USER_CONTEXT_MAX_LEN - 1);
                 bind_[10].buffer = user_context_;
-                bind_[10].buffer_length = ctx_txt.length();
+                bind_[10].buffer_length = std::min(ctx_txt.length(), USER_CONTEXT_MAX_LEN - 1);
                 // bind_[10].is_null = &MLM_FALSE; // commented out for performance
                                                    // reasons, see memset() above
             } else {
@@ -1439,14 +1439,14 @@ public:
         try {
             // address: binary(16)
             addr6_ = lease->addr_.toBytes();
-            if (addr6_.size() != 16) {
+            if (addr6_.size() != isc::asiolink::V6ADDRESS_LEN) {
                 isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
             }
 
-            addr6_length_ = 16;
+            addr6_length_ = isc::asiolink::V6ADDRESS_LEN;
             bind_[0].buffer_type = MYSQL_TYPE_BLOB;
             bind_[0].buffer = reinterpret_cast<char*>(&addr6_[0]);
-            bind_[0].buffer_length = 16;
+            bind_[0].buffer_length = addr6_length_;
             bind_[0].length = &addr6_length_;
             // bind_[0].is_null = &MLM_FALSE; // commented out for performance
                                               // reasons, see memset() above
@@ -1638,7 +1638,7 @@ public:
                 std::string ctx_txt = ctx->str();
                 strncpy(user_context_, ctx_txt.c_str(), USER_CONTEXT_MAX_LEN - 1);
                 bind_[16].buffer = user_context_;
-                bind_[16].buffer_length = ctx_txt.length();
+                bind_[16].buffer_length = std::min(ctx_txt.length(), USER_CONTEXT_MAX_LEN - 1);
                 // bind_[16].is_null = &MLM_FALSE; // commented out for performance
                                                    // reasons, see memset() above
             } else {
@@ -1688,7 +1688,7 @@ public:
         memset(bind_, 0, sizeof(bind_));
 
         // address: binary(16)
-        addr6_length_ = 16;
+        addr6_length_ = isc::asiolink::V6ADDRESS_LEN;
         bind_[0].buffer_type = MYSQL_TYPE_BLOB;
         bind_[0].buffer = reinterpret_cast<char*>(addr6_buffer_);
         bind_[0].buffer_length = addr6_length_;
@@ -2821,7 +2821,7 @@ MySqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const {
 
     // If the data happens to be empty, we have to create a 1 byte dummy
     // buffer and pass it to the binding.
-    std::vector<uint8_t> single_byte_vec(1);
+    uint8_t single_byte_data = 0;
 
     // As "buffer" is "char*" - even though the data is being read - we need
     // to cast away the "const"ness as well as reinterpreting the data as
@@ -2829,7 +2829,7 @@ MySqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const {
     // local variable, but as the data is only being read, this introduces
     // an unnecessary copy).
     uint8_t* data = !hwaddr.hwaddr_.empty() ? const_cast<uint8_t*>(&hwaddr.hwaddr_[0])
-        : &single_byte_vec[0];
+        : &single_byte_data;
 
     inbind[0].buffer = reinterpret_cast<char*>(data);
     inbind[0].buffer_length = hwaddr_length;
@@ -3111,14 +3111,14 @@ MySqlLeaseMgr::getLease6(Lease::Type lease_type,
 
     // address: binary(16)
     std::vector<uint8_t>addr6 = addr.toBytes();
-    if (addr6.size() != 16) {
+    if (addr6.size() != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
     }
 
-    unsigned long addr6_length = 16;
+    unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[0].buffer_length = 16;
+    inbind[0].buffer_length = addr6_length;
     inbind[0].length = &addr6_length;
 
     // LEASE_TYPE
@@ -3204,18 +3204,9 @@ MySqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid,
     // data).  For that reason, "const_cast" has been used.
     const vector<uint8_t>& duid_vector = duid.getDuid();
     unsigned long duid_length = duid_vector.size();
-
-    // Make sure that the buffer has at least length of 1, even if
-    // empty client id is passed. This is required by some of the
-    // MySQL connectors that the buffer is set to non-null value.
-    // Otherwise, null value would be inserted into the database,
-    // rather than empty string.
-    uint8_t single_byte_data = 0;
-    uint8_t* data = !duid_vector.empty() ? const_cast<uint8_t*>(&duid_vector[0])
-        : &single_byte_data;
-
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
-    inbind[0].buffer = reinterpret_cast<char*>(data);
+    inbind[0].buffer = reinterpret_cast<char*>(
+        const_cast<uint8_t*>(&duid_vector[0]));
     inbind[0].buffer_length = duid_length;
     inbind[0].length = &duid_length;
 
@@ -3347,7 +3338,7 @@ MySqlLeaseMgr::getLeases6(SubnetID subnet_id,
     // Bind the lower bound address.
     std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
     unsigned long lb_addr_size = lb_addr_data.size();
-    if (lb_addr_size != 16) {
+    if (lb_addr_size != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
     }
     inbind[1].buffer_type = MYSQL_TYPE_BLOB;
@@ -3397,7 +3388,6 @@ MySqlLeaseMgr::getLeases6(const DUID& duid) const {
 
     const vector<uint8_t>& duid_vector = duid.getDuid();
     unsigned long duid_length = duid_vector.size();
-
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(
             const_cast<uint8_t*>(&duid_vector[0]));
@@ -3522,14 +3512,14 @@ MySqlLeaseMgr::getLeases6(const IOAddress& lower_bound_address,
 
     // Bind lower bound address
     std::vector<uint8_t>lb_addr = lower_bound_address.toBytes();
-    if (lb_addr.size() != 16) {
+    if (lb_addr.size() != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "getLeases6() - lower bound address is not 16 bytes long");
     }
 
-    unsigned long lb_addr_length = 16;
+    unsigned long lb_addr_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(&lb_addr[0]);
-    inbind[0].buffer_length = 16;
+    inbind[0].buffer_length = lb_addr_length;
     inbind[0].length = &lb_addr_length;
 
     // Bind page size value
@@ -3754,14 +3744,14 @@ MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
 
     // Bind the where clause address parameter.
     std::vector<uint8_t>addr6 = lease->addr_.toBytes();
-    if (addr6.size() != 16) {
+    if (addr6.size() != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "updateLease6() - address is not 16 bytes long");
     }
 
-    unsigned long addr6_length = 16;
+    unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[0].buffer_length = 16;
+    inbind[0].buffer_length = addr6_length;
     inbind[0].length = &addr6_length;
 
     bind.push_back(inbind[0]);
@@ -3945,14 +3935,14 @@ MySqlLeaseMgr::deleteLease(const Lease6Ptr& lease) {
 
     // Bind the where clause address parameter.
     std::vector<uint8_t>addr6 = addr.toBytes();
-    if (addr6.size() != 16) {
+    if (addr6.size() != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "deleteLease6() - address is not 16 bytes long");
     }
 
-    unsigned long addr6_length = 16;
+    unsigned long addr6_length = isc::asiolink::V6ADDRESS_LEN;
     inbind[0].buffer_type = MYSQL_TYPE_BLOB;
     inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
-    inbind[0].buffer_length = 16;
+    inbind[0].buffer_length = addr6_length;
     inbind[0].length = &addr6_length;
 
     // See the expire code of createBindForSend for the
@@ -4430,7 +4420,7 @@ MySqlLeaseMgr::addRelayId6(const IOAddress& lease_addr,
     // Bind the lease address.
     std::vector<uint8_t> lease_addr_data = lease_addr.toBytes();
     unsigned long lease_addr_length = lease_addr_data.size();
-    if (lease_addr_length != 16) {
+    if (lease_addr_length != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
     }
     bind[1].buffer_type = MYSQL_TYPE_BLOB;
@@ -4474,7 +4464,7 @@ MySqlLeaseMgr::addRemoteId6(const IOAddress& lease_addr,
     // Bind the lease address.
     std::vector<uint8_t> lease_addr_data = lease_addr.toBytes();
     unsigned long lease_addr_length = lease_addr_data.size();
-    if (lease_addr_length != 16) {
+    if (lease_addr_length != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
     }
     bind[1].buffer_type = MYSQL_TYPE_BLOB;
@@ -4844,7 +4834,7 @@ MySqlLeaseMgr::getLeases6ByRelayId(const DUID& relay_id,
     // Bind the lower bound address.
     std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
     unsigned long lb_addr_size = lb_addr_data.size();
-    if (lb_addr_size != 16) {
+    if (lb_addr_size != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
     }
     inbind[1].buffer_type = MYSQL_TYPE_BLOB;
@@ -4902,7 +4892,7 @@ MySqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
     // Bind the lower bound address.
     std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
     unsigned long lb_addr_size = lb_addr_data.size();
-    if (lb_addr_size != 16) {
+    if (lb_addr_size != isc::asiolink::V6ADDRESS_LEN) {
         isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
     }
     inbind[1].buffer_type = MYSQL_TYPE_BLOB;
@@ -4952,14 +4942,14 @@ MySqlLeaseMgr::upgradeExtendedInfo6(const LeasePageSize& page_size) {
 
         // Bind start address.
         std::vector<uint8_t>start_addr_bytes = start_addr.toBytes();
-        if (start_addr_bytes.size() != 16) {
+        if (start_addr_bytes.size() != isc::asiolink::V6ADDRESS_LEN) {
             isc_throw(DbOperationError, "start address is not 16 bytes long");
         }
 
-        unsigned long start_addr_size = 16;
+        unsigned long start_addr_size = isc::asiolink::V6ADDRESS_LEN;
         inbind[0].buffer_type = MYSQL_TYPE_BLOB;
         inbind[0].buffer = reinterpret_cast<char*>(&start_addr_bytes[0]);
-        inbind[0].buffer_length = 16;
+        inbind[0].buffer_length = start_addr_size;
         inbind[0].length = &start_addr_size;
 
         // Bind page size value.
index 41333bb9c694b49ad21ac2cde006384b63cd83ca..08832d99e238e6eb7dee132153b5344fe01b26b8 100644 (file)
@@ -493,8 +493,7 @@ public:
         int status = 0;
         if (!in_bind_vec.empty()) {
             // Bind parameters to the prepared statement.
-            status = mysql_stmt_bind_param(getStatement(index),
-                                           in_bind_vec.empty() ? 0 : &in_bind_vec[0]);
+            status = mysql_stmt_bind_param(getStatement(index), &in_bind_vec[0]);
             checkError(status, index, "unable to bind parameters for select");
         }