summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2018-12-31 15:41:25 +0100
committerHans Dedecker <dedeckeh@gmail.com>2018-12-31 15:56:35 +0100
commit8f498044938e6ae48a49bc441a21195dd889e632 (patch)
treebc0011b370e1898e5b74bd73efa519c17a446af2 /src
parent2d2a3b840421cfc6328aee8cc52e5a5a51444fda (diff)
config: check for invalid DNS addresses
Don't accept 0.0.0.0 and :: as DNS addresses. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/config.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 9ae8466..9ffe1ac 100644
--- a/src/config.c
+++ b/src/config.c
@@ -580,6 +580,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
struct in_addr addr4;
struct in6_addr addr6;
if (inet_pton(AF_INET, blobmsg_get_string(cur), &addr4) == 1) {
+ if (addr4.s_addr == INADDR_ANY)
+ goto err;
+
iface->dhcpv4_dns = realloc(iface->dhcpv4_dns,
(++iface->dhcpv4_dns_cnt) * sizeof(*iface->dhcpv4_dns));
if (!iface->dhcpv4_dns)
@@ -587,6 +590,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
iface->dhcpv4_dns[iface->dhcpv4_dns_cnt - 1] = addr4;
} else if (inet_pton(AF_INET6, blobmsg_get_string(cur), &addr6) == 1) {
+ if (IN6_IS_ADDR_UNSPECIFIED(&addr6))
+ goto err;
+
iface->dns = realloc(iface->dns,
(++iface->dns_cnt) * sizeof(*iface->dns));
if (!iface->dns)