From 7496f70e45964d9e4ac870582c8e4e3ce7c56ad6 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 22 Jan 2013 16:42:40 +0100 Subject: [PATCH] Don't segfault with an unset ula_prefix --- interface-ip.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); -- 2.30.2