diff options
author | Steven Barth <steven@midlink.org> | 2014-02-14 21:09:05 +0100 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-02-14 21:09:05 +0100 |
commit | b8c54175393d6cfd07ea641230bd785ce9aee0cc (patch) | |
tree | 07dcd22fd4d33064966621b63eb5879560d123e0 /interface-ip.c | |
parent | 8495bc0176185ca77eae770a33b3463ca2bc0f25 (diff) | |
download | netifd-b8c54175393d6cfd07ea641230bd785ce9aee0cc.tar.gz |
Fix source-restrictions of routes when no mask was provided
Diffstat (limited to 'interface-ip.c')
-rw-r--r-- | interface-ip.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/interface-ip.c b/interface-ip.c index 59cf828..fed7d72 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -337,12 +337,12 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) const char *addr = strtok_r(source, "/", &saveptr); const char *mask = strtok_r(NULL, "/", &saveptr); - if (inet_pton(af, addr, &route->source) < 1) { + if (!addr || inet_pton(af, addr, &route->source) < 1) { DPRINTF("Failed to parse route source: %s\n", addr); goto error; } - route->sourcemask = atoi(mask); + route->sourcemask = (mask) ? atoi(mask) : ((af == AF_INET6) ? 128 : 32); } if (is_proto_route) { |