The rev-server directive only handles the following CIDR prefixes
properly: /8, /16, /24, /32.
Any other value was silently converted to /16 which could result in
unexpected behaviour.
This patch rejects any other value instead of making a silent
conversion.
Signed-off-by: Olivier Gayot
---
src/option.c | 12 ++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/option.c b/src/option.c
index 548560c..0e1beb0 100644
--- a/src/option.c
+++ b/src/option.c
@@ -864,13 +864,14 @@ static struct server *add_rev4(struct in_addr addr, int
msize)
case 24:
p += sprintf(p, "%d.", (a >> 8) & 0xff);
/* fall through */
-default:
case 16:
p += sprintf(p, "%d.", (a >> 16) & 0xff);
/* fall through */
case 8:
p += sprintf(p, "%d.", (a >> 24) & 0xff);
break;
+default:
+ return NULL;
}
p += sprintf(p, "in-addr.arpa");
@@ -2078,6 +2079,9 @@ static int one_opt(int option, char *arg, char *errstr,
char *gen_err, int comma
/* generate the equivalent of
local=/xxx.yyy.zzz.in-addr.arpa/ */
struct server *serv = add_rev4(new->start,
msize);
+ if (!serv)
+ ret_err(_("bad prefix"));
+
serv->flags |= SERV_NO_ADDR;
/* local=// */
@@ -2449,7 +2453,11 @@ static int one_opt(int option, char *arg, char *errstr,
char *gen_err, int comma
ret_err(gen_err);
if (inet_pton(AF_INET, arg, ))
- serv = add_rev4(addr4, size);
+ {
+ serv = add_rev4(addr4, size);
+ if (!serv)
+ ret_err(_("bad prefix"));
+ }
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, ))
serv = add_rev6(, size);
--
2.12.0
___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss