From: Hans Dedecker Date: Mon, 4 Jun 2018 20:07:13 +0000 (+0200) Subject: router: fix possible segfault in send_router_advert() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=676eb383867f9bcbf3a692fc56eadff6d7cfc72c;p=project%2Fodhcpd.git router: fix possible segfault in send_router_advert() Detected by Coverity in CID1412349 Signed-off-by: Hans Dedecker --- diff --git a/src/router.c b/src/router.c index 777cbc0..8e3013c 100644 --- a/src/router.c +++ b/src/router.c @@ -569,9 +569,11 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add search->len = search_len ? ((sizeof(*search) + search_padded) / 8) : 0; search->pad = 0; search->pad2 = 0; - memcpy(search->name, search_domain, search_len); - memset(&search->name[search_len], 0, search_padded - search_len); + if (search_len > 0) { + memcpy(search->name, search_domain, search_len); + memset(&search->name[search_len], 0, search_padded - search_len); + } size_t routes_cnt = 0; struct {