]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2086] Updated lease parser
authorFrancis Dupont <fdupont@isc.org>
Tue, 14 Jun 2022 09:01:05 +0000 (11:01 +0200)
committerRazvan Becheriu <razvan@isc.org>
Thu, 23 Jun 2022 19:19:44 +0000 (22:19 +0300)
src/lib/dhcpsrv/lease.cc
src/lib/dhcpsrv/tests/lease_unittest.cc

index fbb51467ed109453c7faf413db82aacf2c5d6f37..e9a2c3d11b84bbaa7b1b5c7fa1ea02d838330862 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2021 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2022 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -173,7 +173,10 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
 
     if (subnet_id->intValue() <= 0) {
         isc_throw(BadValue, "subnet-id " << subnet_id->intValue() << " is not"
-                            << " a positive integer");
+                  << " a positive integer");
+    } else if (subnet_id->intValue() > numeric_limits<uint32_t>::max()) {
+        isc_throw(BadValue, "subnet-id " << subnet_id->intValue() << " is not"
+                  << " a 32 bit unsigned integer");
     }
 
     lease->subnet_id_ = SubnetID(subnet_id->intValue());
index 92e1d21a4f45f51222b078ec86ba6cc91ee98315..9fae66dd093a91617aa64bd8500e12c2bf224d65 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2022 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -622,6 +622,7 @@ TEST_F(Lease4Test, fromElementInvalidValues) {
     testInvalidElement<Lease4>(json, "state", 1234, false);
     testInvalidElement<Lease4>(json, "subnet-id", std::string("xyz"));
     testInvalidElement<Lease4>(json, "subnet-id", -5, false);
+    testInvalidElement<Lease4>(json, "subnet-id", 0x100000000, false);
     testInvalidElement<Lease4>(json, "valid-lft", std::string("xyz"));
     testInvalidElement<Lease4>(json, "valid-lft", -3, false);
     testInvalidElement<Lease4>(json, "user-context", "[ ]", false);
@@ -1362,6 +1363,7 @@ TEST(Lease6Test, fromElementInvalidValues) {
     testInvalidElement<Lease6>(json, "state", 1234, false);
     testInvalidElement<Lease6>(json, "subnet-id", std::string("xyz"));
     testInvalidElement<Lease6>(json, "subnet-id", -5, false);
+    testInvalidElement<Lease6>(json, "subnet-id", 0x100000000, false);
     testInvalidElement<Lease6>(json, "type", std::string("IA_XY"));
     testInvalidElement<Lease6>(json, "type", -3, false);
     testInvalidElement<Lease6>(json, "valid-lft", std::string("xyz"));