X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=interface-ip.c;h=fed7d725c7c37b7b9742aa3300c81c3729747966;hp=59cf82809cdffcb9ff98ef6a9720f723bc1b59ee;hb=b8c54175393d6cfd07ea641230bd785ce9aee0cc;hpb=8495bc0176185ca77eae770a33b3463ca2bc0f25;ds=inline 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) {