From: Razvan Becheriu Date: Wed, 28 Oct 2020 08:54:27 +0000 (+0200) Subject: [#1405] fixed reservation access on empty hosts X-Git-Tag: Kea-1.9.2~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73d56545f9cba858f4c8359594044ec9716517d2;p=thirdparty%2Fkea.git [#1405] fixed reservation access on empty hosts --- diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 6e20d4a1c0..312fad7710 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -3037,12 +3037,14 @@ hasAddressReservation(AllocEngine::ClientContext4& ctx) { auto host = ctx.hosts_.find(subnet->getID()); bool in_subnet = (subnet->getHostReservationMode() & Network::HR_IN_SUBNET); bool out_of_pool = (subnet->getHostReservationMode() & Network::HR_OUT_OF_POOL); - auto reservation = host->second->getIPv4Reservation(); - if ((host != ctx.hosts_.end()) && !reservation.isV4Zero() && - ((in_subnet && !out_of_pool) || - (out_of_pool && !subnet->inPool(Lease::TYPE_V4, reservation)))) { - ctx.subnet_ = subnet; - return (true); + if (host != ctx.hosts_.end()) { + auto reservation = host->second->getIPv4Reservation(); + if (!reservation.isV4Zero() && + ((in_subnet && !out_of_pool) || + (out_of_pool && !subnet->inPool(Lease::TYPE_V4, reservation)))) { + ctx.subnet_ = subnet; + return (true); + } } // No address reservation found here, so let's try another subnet