summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2016-03-03 20:33:54 +0000
committerSimon Kelley <simon@thekelleys.org.uk>2016-03-03 20:33:54 +0000
commitfa79466c2a7f92895aa9a48b7ef411f634ebef2f (patch)
treed6959417b700343e92b1b313bffa8121a97ec905
parenta93bd4b0160e2e201e54021a79ea71e135fbe41b (diff)
downloaddnsmasq-2.76test12.tar.gz
Tighten syntax checking for dhcp-range and clarify man page.v2.76test12
-rw-r--r--man/dnsmasq.82
-rw-r--r--src/option.c16
2 files changed, 11 insertions, 7 deletions
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
index 3cf48cd..fd4b7c5 100644
--- a/man/dnsmasq.8
+++ b/man/dnsmasq.8
@@ -783,7 +783,7 @@ compiled in and the kernel must have conntrack support
included and configured. This option cannot be combined with
--query-port.
.TP
-.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>]
+.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-addr>[,<end-addr>|<mode>][,<netmask>[,<broadcast>]][,<lease time>]
.TP
.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-IPv6addr>[,<end-IPv6addr>|constructor:<interface>][,<mode>][,<prefix-len>][,<lease time>]
diff --git a/src/option.c b/src/option.c
index c1f8b5a..bedad7b 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2772,13 +2772,14 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
leasepos = 3;
if (!is_same_net(new->start, new->end, new->netmask))
ret_err(_("inconsistent DHCP range"));
- }
+
- if (k >= 4 && strchr(a[3], '.') &&
- (inet_pton(AF_INET, a[3], &new->broadcast) > 0))
- {
- new->flags |= CONTEXT_BRDCAST;
- leasepos = 4;
+ if (k >= 4 && strchr(a[3], '.') &&
+ (inet_pton(AF_INET, a[3], &new->broadcast) > 0))
+ {
+ new->flags |= CONTEXT_BRDCAST;
+ leasepos = 4;
+ }
}
}
#ifdef HAVE_DHCP6
@@ -2868,6 +2869,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
if (leasepos < k)
{
+ if (leasepos != k-1)
+ ret_err(_("bad dhcp-range"));
+
if (strcmp(a[leasepos], "infinite") == 0)
new->lease_time = 0xffffffff;
else if (strcmp(a[leasepos], "deprecated") == 0)