From: Marcin Siodelski Date: Tue, 20 Sep 2016 13:37:11 +0000 (+0200) Subject: [5009] Addressed review comments. X-Git-Tag: trac5049_base~13^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07fbb6e142a5176203ef096edab172e4ba4f8cb8;p=thirdparty%2Fkea.git [5009] Addressed review comments. --- diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index 927f10a13f..2c8123681f 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -822,6 +822,11 @@ private: space.assign(space_); } + // If empty or null space provided, use a default top level space. + if (space.empty()) { + space = (universe_ == Option::V4 ? "dhcp4" : "dhcp6"); + } + // Convert formatted_value to string as well. std::string formatted_value; if (formatted_value_null_ == MLM_FALSE) { diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc index cf2094ad42..b1dce8033b 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc @@ -506,6 +506,11 @@ private: PgSqlExchange::getColumnValue(r, row, space_index_, space); } + // If empty or null space provided, use a default top level space. + if (space.empty()) { + space = (universe_ == Option::V4 ? "dhcp4" : "dhcp6"); + } + // persistent: BOOL default false bool persistent; PgSqlExchange::getColumnValue(r, row, persistent_index_, diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index c8a62d6ade..9d64acdc96 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -581,6 +581,15 @@ public: /// @throw DbOperationError if the lease cannot be created. Lease6Ptr convertFromDatabase(const PgSqlResult& r, int row) { try { + + /// @todo In theory, an administrator could tweak lease + /// information in the database. In this case, some of the + /// values could be set to NULL. This is less likely than + /// in case of host reservations, but we may consider if + /// retrieved values should be checked for being NULL to + /// prevent cryptic errors during conversions from NULL + /// to actual values. + isc::asiolink::IOAddress addr(getIPv6Value(r, row, ADDRESS_COL)); convertFromBytea(r, row, DUID_COL, duid_buffer_,