diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-06-04 22:07:13 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2018-06-04 22:07:13 +0200 |
commit | 676eb383867f9bcbf3a692fc56eadff6d7cfc72c (patch) | |
tree | a7508733f0bff4e3ce7a93492d1d8558727dcf8a | |
parent | 392701f80a31cf1b3781f9931ba398a1944894ef (diff) |
router: fix possible segfault in send_router_advert()
Detected by Coverity in CID1412349
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r-- | src/router.c | 6 |
1 files 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 { |