]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2260] Addressed (updated) second item
authorFrancis Dupont <fdupont@isc.org>
Wed, 1 Jul 2026 16:20:13 +0000 (18:20 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 10 Jul 2026 10:39:15 +0000 (12:39 +0200)
src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds4_unittest.cc
src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds6_unittest.cc

index f4552ebcb9d30afba2c72c76146571620efe9473..4b577addd21a984927188324cb8158ec62c981a2 100644 (file)
@@ -1199,7 +1199,12 @@ LeaseCmdsImpl::leaseGetByClientIdHandler(CalloutHandle& handle) {
             isc_throw(BadValue, "'client-id' parameter must be a string");
         }
 
-        ClientIdPtr clientid = ClientId::fromText(client_id->stringValue());
+        ClientIdPtr clientid;
+        try {
+            clientid = ClientId::fromText(client_id->stringValue());
+        } catch (const std::exception& ex) {
+            isc_throw(BadValue, "bad 'client-id' parameter: " << ex.what());
+        }
 
         Lease4Collection leases =
             LeaseMgrFactory::instance().getLease4(*clientid);
@@ -1249,7 +1254,12 @@ LeaseCmdsImpl::leaseGetByDuidHandler(CalloutHandle& handle) {
             isc_throw(BadValue, "'duid' parameter must be a string");
         }
 
-        DUID duid_ = DUID::fromText(duid->stringValue());
+        DUID duid_ = DUID::EMPTY();
+        try {
+            duid_ = DUID::fromText(duid->stringValue());
+        } catch (const std::exception& ex) {
+            isc_throw(BadValue, "bad 'duid' parameter: " << ex.what());
+        }
 
         Lease6Collection leases =
             LeaseMgrFactory::instance().getLeases6(duid_);
index 40c12c0fe1a975957c26daccb27b1d563413ffb2..0c2d7ddd640c0510f0197a5cec5ec0354df85334 100644 (file)
@@ -2006,7 +2006,8 @@ void Lease4CmdsTest::testLease4GetByClientIdParams() {
         "        \"client-id\": \"00::01:00:bc:0d:67\"\n"
         "    }\n"
         "}";
-    exp_rsp = "two consecutive separators (':') specified in a decoded string";
+    exp_rsp = "bad 'client-id' parameter: ";
+    exp_rsp += "two consecutive separators (':') specified in a decoded string";
     exp_rsp += " '00::01:00:bc:0d:67'";
     testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
 }
index 9fbe4a7bbbbd82f8a845c11e6f66e3d5d9759257..a3f1c65211532b71d6ff492dd7180aacc90b909a 100644 (file)
@@ -2270,7 +2270,8 @@ void Lease6CmdsTest::testLease6GetByDuidParams() {
         "        \"duid\": \"00::01:00:bc:0d:67\"\n"
         "    }\n"
         "}";
-    exp_rsp = "two consecutive separators (':') specified in a decoded string";
+    exp_rsp = "bad 'duid' parameter: ";
+    exp_rsp += "two consecutive separators (':') specified in a decoded string";
     exp_rsp += " '00::01:00:bc:0d:67'";
     testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
 }