diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2019-04-19 13:16:58 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-04-19 19:17:38 +0200 |
commit | 6633efeb8196853503305c2714ba6830c8d9c70b (patch) | |
tree | 276a18f928cc258dd192ec8b419abaf19d0f47ef | |
parent | 38bc630be6816eb5bd0a368437c97ee1aba3ee56 (diff) |
router: fix dns search list option
Fix regression issue introduced in commit 0523bdd as empty DNS search
list option was sent making the RA message invalid
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r-- | src/router.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/router.c b/src/router.c index a897d5b..3a6b121 100644 --- a/src/router.c +++ b/src/router.c @@ -587,7 +587,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr /* DNS options */ if (iface->ra_dns) { struct in6_addr dns_pref, *dns_addr = NULL; - size_t dns_cnt = 0, search_padded = 0, search_len = iface->search_len; + size_t dns_cnt = 0, search_len = iface->search_len; uint8_t *search_domain = iface->search; /* DNS Recursive DNS */ @@ -622,18 +622,16 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr } } - if (search_len > 0) - search_padded = ((search_len + 7) & (~7)) + 8; - - search_sz = sizeof(*search) + search_padded; + if (search_len > 0) { + size_t search_padded = ((search_len + 7) & (~7)) + 8; - search = alloca(search_sz); - memset(search, 0, search_sz); - search->type = ND_OPT_DNS_SEARCH; - search->len = search_len ? ((sizeof(*search) + search_padded) / 8) : 0; - search->lifetime = htonl(lifetime); + search_sz = sizeof(*search) + search_padded; - if (search_len > 0) { + search = alloca(search_sz); + memset(search, 0, search_sz); + search->type = ND_OPT_DNS_SEARCH; + search->len = search_len ? ((sizeof(*search) + search_padded) / 8) : 0; + search->lifetime = htonl(lifetime); memcpy(search->name, search_domain, search_len); memset(&search->name[search_len], 0, search_padded - search_len); } |