From: Marcin Siodelski Date: Tue, 27 Nov 2018 21:00:38 +0000 (+0100) Subject: [#27,!138] Guard against null host in cql host data source. X-Git-Tag: 284-need-dhcp6-example-for-netconf_base~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8666ed4754ffd27f3aa46a2cf3e4b161a1d877ee;p=thirdparty%2Fkea.git [#27,!138] Guard against null host in cql host data source. --- diff --git a/src/lib/dhcpsrv/cql_host_data_source.cc b/src/lib/dhcpsrv/cql_host_data_source.cc index c70055a9dc..6f7648ebef 100644 --- a/src/lib/dhcpsrv/cql_host_data_source.cc +++ b/src/lib/dhcpsrv/cql_host_data_source.cc @@ -1621,6 +1621,11 @@ CqlHostDataSourceImpl::~CqlHostDataSourceImpl() { bool CqlHostDataSourceImpl::insertOrDelete(const HostPtr& host, bool insert) { + // If there is no host, there is nothing to do. + if (!host) { + return (false); + } + // Get option space names and vendor space names and combine them within a // single list. @@ -1859,6 +1864,11 @@ CqlHostDataSourceImpl::insertOrDeleteHostWithOptions(bool insert, const IPv6Resrv* const reservation, const std::list& option_spaces, const ConstCfgOptionPtr cfg_option) { + // If there is no host, there is nothing to do. + if (!host) { + return (false); + } + bool result = true; // For each option space retrieve all options and insert them into @@ -1897,6 +1907,11 @@ CqlHostDataSourceImpl::insertOrDeleteHostWithReservations(bool insert, const ConstCfgOptionPtr cfg_option4, const std::list& option_spaces6, const ConstCfgOptionPtr cfg_option6) { + // If there is no host, there is nothing to do. + if (!host) { + return (false); + } + bool result = true; // If host has no reservation, add entries with null reservation. @@ -1979,6 +1994,11 @@ CqlHostDataSourceImpl::insertOrDeleteHost(bool insert, const IPv6Resrv* const reservation, const std::string& option_space, const OptionDescriptor& option_descriptor) { + // If there is no host, there is nothing to do. + if (!host) { + return (false); + } + AnyArray assigned_values; std::unique_ptr host_exchange(new CqlHostExchange());