summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-02-07 12:52:51 +0000
committerRoy Marples <roy@marples.name>2020-02-07 12:53:32 +0000
commit30a2e20cccb10e8865ca3b75c381bb5411e5f603 (patch)
treeb7ad090fa5b6ba7216144a4c3fdd1d994eda52a8
parentd3c3fe30d6acffdc7cc59aa7bcc51952b35071ad (diff)
downloaddhcpcd-30a2e20cccb10e8865ca3b75c381bb5411e5f603.tar.xz
options: Improve AF_INET6 address parsing and logging
-rw-r--r--src/if-options.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/if-options.c b/src/if-options.c
index f922cfc1..ccfb2a7e 100644
--- a/src/if-options.c
+++ b/src/if-options.c
@@ -1165,7 +1165,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
np = strchr(p, '/');
if (np)
*np++ = '\0';
- if (inet_pton(AF_INET6, p, &ifo->req_addr6) == 1) {
+ if ((i = inet_pton(AF_INET6, p, &ifo->req_addr6)) == 1) {
if (np) {
ifo->req_prefix_len = (uint8_t)strtou(np,
NULL, 0, 0, 128, &e);
@@ -1178,6 +1178,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
} else
ifo->req_prefix_len = 128;
}
+ if (np)
+ *(--np) = '\0';
+ if (i != 1) {
+ logerrx("invalid AF_INET6: %s", p);
+ memset(&ifo->req_addr6, 0,
+ sizeof(ifo->req_addr6));
+ return -1;
+ }
} else
add_environ(&ifo->config, arg, 1);
break;
@@ -1398,8 +1406,8 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
p = strchr(arg, '/');
if (p)
*p++ = '\0';
- if (inet_pton(AF_INET6, arg, &ia->addr) == -1) {
- logerr("%s", arg);
+ if (inet_pton(AF_INET6, arg, &ia->addr) != 1) {
+ logerrx("invalid AF_INET6: %s", arg);
memset(&ia->addr, 0, sizeof(ia->addr));
}
if (p && ia->ia_type == D6_OPTION_IA_PD) {