From 676eb383867f9bcbf3a692fc56eadff6d7cfc72c Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Mon, 4 Jun 2018 22:07:13 +0200 Subject: router: fix possible segfault in send_router_advert() Detected by Coverity in CID1412349 Signed-off-by: Hans Dedecker --- src/router.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 { -- cgit v1.2.3