From: Steven Barth Date: Tue, 22 Jan 2013 15:42:40 +0000 (+0100) Subject: Don't segfault with an unset ula_prefix X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7496f70e45964d9e4ac870582c8e4e3ce7c56ad6;p=oweals%2Fnetifd.git Don't segfault with an unset ula_prefix --- diff --git a/interface-ip.c b/interface-ip.c index 892631d..ea4c3dd 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -634,12 +634,18 @@ void interface_ip_set_ula_prefix(const char *prefix) { char buf[INET6_ADDRSTRLEN + 4] = {0}, *saveptr; - strncpy(buf, prefix, sizeof(buf) - 1); + if (prefix) + strncpy(buf, prefix, sizeof(buf) - 1); char *prefixaddr = strtok_r(buf, "/", &saveptr); struct in6_addr addr; - if (!prefixaddr || inet_pton(AF_INET6, prefixaddr, &addr) < 1) + if (!prefixaddr || inet_pton(AF_INET6, prefixaddr, &addr) < 1) { + if (ula_prefix) { + interface_update_prefix(NULL, NULL, &ula_prefix->node); + ula_prefix = NULL; + } return; + } int length; char *prefixlen = strtok_r(NULL, ",", &saveptr);