From: Razvan Becheriu Date: Mon, 3 Aug 2026 12:39:13 +0000 (+0300) Subject: [#4691] always use buffer size on send X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c618c2cd215e22ea4d9924c74241a385ba0d332;p=thirdparty%2Fkea.git [#4691] always use buffer size on send --- diff --git a/ChangeLog b/ChangeLog index c60cdbb9ed..7a80eb4c62 100644 --- 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) diff --git a/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc b/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc index c9189f5aeb..ee07e6ca62 100644 --- a/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc +++ b/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc @@ -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(); diff --git a/src/hooks/dhcp/lease_query/lease_query_impl6.cc b/src/hooks/dhcp/lease_query/lease_query_impl6.cc index 4ecb98e51b..237c5ab4d7 100644 --- a/src/hooks/dhcp/lease_query/lease_query_impl6.cc +++ b/src/hooks/dhcp/lease_query/lease_query_impl6.cc @@ -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_) { diff --git a/src/hooks/dhcp/mysql/mysql_host_data_source.cc b/src/hooks/dhcp/mysql/mysql_host_data_source.cc index dfc7a08c20..36c2861e6c 100644 --- a/src/hooks/dhcp/mysql/mysql_host_data_source.cc +++ b/src/hooks/dhcp/mysql/mysql_host_data_source.cc @@ -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(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(&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(&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(&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 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(hostname_); + inbind[0].buffer = reinterpret_cast(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(hostname_); + inbind[0].buffer = reinterpret_cast(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(hostname_); + inbind[0].buffer = reinterpret_cast(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(&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(&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(&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(&addr6[0]); - inbind[0].buffer_length = isc::asiolink::V6ADDRESS_LEN; + inbind[0].buffer_length = addr6_length; inbind[0].length = &addr6_length; ConstHostCollection collection; diff --git a/src/hooks/dhcp/mysql/mysql_lease_mgr.cc b/src/hooks/dhcp/mysql/mysql_lease_mgr.cc index 3d94a2cf35..b4346dc01a 100644 --- a/src/hooks/dhcp/mysql/mysql_lease_mgr.cc +++ b/src/hooks/dhcp/mysql/mysql_lease_mgr.cc @@ -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(&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(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 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(&hwaddr.hwaddr_[0]) - : &single_byte_vec[0]; + : &single_byte_data; inbind[0].buffer = reinterpret_cast(data); inbind[0].buffer_length = hwaddr_length; @@ -3111,14 +3111,14 @@ MySqlLeaseMgr::getLease6(Lease::Type lease_type, // address: binary(16) std::vectoraddr6 = 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(&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& 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(&duid_vector[0]) - : &single_byte_data; - inbind[0].buffer_type = MYSQL_TYPE_BLOB; - inbind[0].buffer = reinterpret_cast(data); + inbind[0].buffer = reinterpret_cast( + const_cast(&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 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& duid_vector = duid.getDuid(); unsigned long duid_length = duid_vector.size(); - inbind[0].buffer_type = MYSQL_TYPE_BLOB; inbind[0].buffer = reinterpret_cast( const_cast(&duid_vector[0])); @@ -3522,14 +3512,14 @@ MySqlLeaseMgr::getLeases6(const IOAddress& lower_bound_address, // Bind lower bound address std::vectorlb_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(&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::vectoraddr6 = 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(&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::vectoraddr6 = 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(&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 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 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 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 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::vectorstart_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(&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. diff --git a/src/lib/mysql/mysql_connection.h b/src/lib/mysql/mysql_connection.h index 41333bb9c6..08832d99e2 100644 --- a/src/lib/mysql/mysql_connection.h +++ b/src/lib/mysql/mysql_connection.h @@ -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"); }