From b8c54175393d6cfd07ea641230bd785ce9aee0cc Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 14 Feb 2014 21:09:05 +0100 Subject: [PATCH] Fix source-restrictions of routes when no mask was provided --- interface-ip.c | 4 ++-- 1 file 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) { -- 2.25.1