]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1405] fixed reservation access on empty hosts
authorRazvan Becheriu <razvan@isc.org>
Wed, 28 Oct 2020 08:54:27 +0000 (10:54 +0200)
committerRazvan Becheriu <razvan@isc.org>
Wed, 18 Nov 2020 13:55:23 +0000 (15:55 +0200)
src/lib/dhcpsrv/alloc_engine.cc

index 6e20d4a1c0fa4e3c8914f493f96ef8ba54bf8499..312fad771002486b2bba44aadf670b97d06b366f 100644 (file)
@@ -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