mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Improve error checking for --rev-server.
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.
This commit is contained in:
committed by
Simon Kelley
parent
916959c188
commit
dc99058d83
12
src/option.c
12
src/option.c
@@ -864,13 +864,14 @@ static struct server *add_rev4(struct in_addr addr, int msize)
|
|||||||
case 24:
|
case 24:
|
||||||
p += sprintf(p, "%d.", (a >> 8) & 0xff);
|
p += sprintf(p, "%d.", (a >> 8) & 0xff);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
|
||||||
case 16:
|
case 16:
|
||||||
p += sprintf(p, "%d.", (a >> 16) & 0xff);
|
p += sprintf(p, "%d.", (a >> 16) & 0xff);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 8:
|
case 8:
|
||||||
p += sprintf(p, "%d.", (a >> 24) & 0xff);
|
p += sprintf(p, "%d.", (a >> 24) & 0xff);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += sprintf(p, "in-addr.arpa");
|
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
|
/* generate the equivalent of
|
||||||
local=/xxx.yyy.zzz.in-addr.arpa/ */
|
local=/xxx.yyy.zzz.in-addr.arpa/ */
|
||||||
struct server *serv = add_rev4(new->start, msize);
|
struct server *serv = add_rev4(new->start, msize);
|
||||||
|
if (!serv)
|
||||||
|
ret_err(_("bad prefix"));
|
||||||
|
|
||||||
serv->flags |= SERV_NO_ADDR;
|
serv->flags |= SERV_NO_ADDR;
|
||||||
|
|
||||||
/* local=/<domain>/ */
|
/* local=/<domain>/ */
|
||||||
@@ -2449,7 +2453,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
|
|
||||||
if (inet_pton(AF_INET, arg, &addr4))
|
if (inet_pton(AF_INET, arg, &addr4))
|
||||||
serv = add_rev4(addr4, size);
|
{
|
||||||
|
serv = add_rev4(addr4, size);
|
||||||
|
if (!serv)
|
||||||
|
ret_err(_("bad prefix"));
|
||||||
|
}
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
else if (inet_pton(AF_INET6, arg, &addr6))
|
else if (inet_pton(AF_INET6, arg, &addr6))
|
||||||
serv = add_rev6(&addr6, size);
|
serv = add_rev6(&addr6, size);
|
||||||
|
|||||||
Reference in New Issue
Block a user