From: Razvan Becheriu Date: Mon, 3 Aug 2026 17:23:32 +0000 (+0300) Subject: [#4691] addressed review comments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5642c0cdb4101dd16fad5ee8a9549685a6042ef0;p=thirdparty%2Fkea.git [#4691] addressed review comments --- diff --git a/ChangeLog b/ChangeLog index 7a80eb4c62..2aea11fb81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2524. [bug] razvan +2525. [bug] razvan Corrected MLM_MYSQL_FETCH_FAILURE to 1 so MySQL selectQuery and host lookups detect mysql_stmt_fetch errors instead of silently ignoring them. diff --git a/src/hooks/dhcp/mysql/mysql_lease_mgr.cc b/src/hooks/dhcp/mysql/mysql_lease_mgr.cc index b4346dc01a..6ea75215c1 100644 --- a/src/hooks/dhcp/mysql/mysql_lease_mgr.cc +++ b/src/hooks/dhcp/mysql/mysql_lease_mgr.cc @@ -894,16 +894,7 @@ public: if (lease_->client_id_) { client_id_ = lease_->client_id_->getClientId(); client_id_length_ = client_id_.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. - if (client_id_.empty()) { - client_id_.resize(1); - } - + // ClientID constructor throws if the size is outside [2, 255] (can not be empty). bind_[2].buffer_type = MYSQL_TYPE_BLOB; bind_[2].buffer = reinterpret_cast(&client_id_[0]); bind_[2].buffer_length = client_id_length_; @@ -1458,7 +1449,7 @@ public: } duid_ = lease_->duid_->getDuid(); duid_length_ = duid_.size(); - + // DUID constructor throws if the size is outside [3, 130] (can not be empty). bind_[1].buffer_type = MYSQL_TYPE_BLOB; bind_[1].buffer = reinterpret_cast(&(duid_[0])); bind_[1].buffer_length = duid_length_; @@ -2864,13 +2855,7 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid) const { std::vector client_data = clientid.getClientId(); unsigned long client_data_length = client_data.size(); - - // If the data happens to be empty, we have to create a 1 byte dummy - // buffer and pass it to the binding. - if (client_data.empty()) { - client_data.resize(1); - } - + // ClientID constructor throws if the size is outside [2, 255] (can not be empty). inbind[0].buffer = reinterpret_cast(&client_data[0]); inbind[0].buffer_length = client_data_length; inbind[0].length = &client_data_length; @@ -2901,13 +2886,7 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const { std::vector client_data = clientid.getClientId(); unsigned long client_data_length = client_data.size(); - - // If the data happens to be empty, we have to create a 1 byte dummy - // buffer and pass it to the binding. - if (client_data.empty()) { - client_data.resize(1); - } - + // ClientID constructor throws if the size is outside [2, 255] (can not be empty). inbind[0].buffer = reinterpret_cast(&client_data[0]); inbind[0].buffer_length = client_data_length; inbind[0].length = &client_data_length; @@ -3204,9 +3183,10 @@ 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(); + // DUID constructor throws if the size is outside [3, 130] (can not be empty). inbind[0].buffer_type = MYSQL_TYPE_BLOB; inbind[0].buffer = reinterpret_cast( - const_cast(&duid_vector[0])); + const_cast(&duid_vector[0])); inbind[0].buffer_length = duid_length; inbind[0].length = &duid_length; @@ -3249,6 +3229,7 @@ MySqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID& duid, // the DUID for an explanation of the reason. const vector& duid_vector = duid.getDuid(); unsigned long duid_length = duid_vector.size(); + // DUID constructor throws if the size is outside [3, 130] (can not be empty). inbind[0].buffer_type = MYSQL_TYPE_BLOB; inbind[0].buffer = reinterpret_cast( const_cast(&duid_vector[0])); @@ -3388,6 +3369,7 @@ MySqlLeaseMgr::getLeases6(const DUID& duid) const { const vector& duid_vector = duid.getDuid(); unsigned long duid_length = duid_vector.size(); + // DUID constructor throws if the size is outside [3, 130] (can not be empty). inbind[0].buffer_type = MYSQL_TYPE_BLOB; inbind[0].buffer = reinterpret_cast( const_cast(&duid_vector[0]));