summaryrefslogtreecommitdiffstats
path: root/src/if-options.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-05-09 12:29:40 +0100
committerRoy Marples <roy@marples.name>2017-05-09 12:29:40 +0100
commitf96eff45c257a7d70b6412db8ccf8c6bb5666839 (patch)
tree1d9152c0553da74100956b24a33efa30c77993cb /src/if-options.c
parent7921378657f6a40365cedac083a97fc1d7e44540 (diff)
downloaddhcpcd-f96eff45c257a7d70b6412db8ccf8c6bb5666839.tar.xz
Don't crash when --static routers= is given on the command line.
T116 will make it work for the control socket.
Diffstat (limited to 'src/if-options.c')
-rw-r--r--src/if-options.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/if-options.c b/src/if-options.c
index 0f5be071..3edc0dbe 100644
--- a/src/if-options.c
+++ b/src/if-options.c
@@ -1066,8 +1066,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
strncmp(arg, "ms_classless_static_routes=",
strlen("ms_classless_static_routes=")) == 0)
{
+ struct interface *ifp;
struct in_addr addr3;
+ ifp = if_find(ctx->ifaces, ifname);
+ if (ifp == NULL) {
+ logerrx("static routes require an interface");
+ return -1;
+ }
fp = np = strwhite(p);
if (np == NULL) {
logerrx("all routes need a gateway");
@@ -1081,7 +1087,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
*fp = ' ';
return -1;
}
- if ((rt = rt_new(if_find(ctx->ifaces, ifname))) == NULL) {
+ if ((rt = rt_new(ifp)) == NULL) {
*fp = ' ';
return -1;
}
@@ -1091,9 +1097,16 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
TAILQ_INSERT_TAIL(&ifo->routes, rt, rt_next);
*fp = ' ';
} else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
+ struct interface *ifp;
+
+ ifp = if_find(ctx->ifaces, ifname);
+ if (ifp == NULL) {
+ logerrx("static routes require an interface");
+ return -1;
+ }
if (parse_addr(&addr, NULL, p) == -1)
return -1;
- if ((rt = rt_new(if_find(ctx->ifaces, ifname))) == NULL)
+ if ((rt = rt_new(ifp)) == NULL)
return -1;
addr2.s_addr = INADDR_ANY;
sa_in_init(&rt->rt_dest, &addr2);