[Dnsmasq-discuss] [PATCH] dhcp-host option: error out on multiple host names

Reynir Björnsson reynir at reynir.dk
Wed Nov 27 12:40:32 UTC 2024


Please find below a patch that will error out on multiple host names 
passed to --dhcp-host. Please also excuse me if I am making mistakes as 
this is the first time I try to contribute to dnsmasq.

Best,
Reynir Björnsson

---

dhcp-host option: error out on multiple host names

Only one host name is allowed. So instead of silently ignoring all but
the last host name we error out.
---
  src/option.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/src/option.c b/src/option.c
index ed0d9e1..536ea12 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4146,6 +4146,12 @@ static int one_opt(int option, char *arg, char 
*errstr, char *gen_err, int comma
  		      new->flags |= CONFIG_DISABLE;
  		    else
  		      {
+			if (new->hostname)
+			  {
+			    dhcp_config_free(new);
+			    ret_err(_("multiple DHCP host names"));
+			  }
+
  			if (!(new->hostname = canonicalise_opt(arg)) ||
  			    !legal_hostname(new->hostname))
  			  {
-- 
2.39.5



More information about the Dnsmasq-discuss mailing list