From a9c8d4d92492313d62a995fd948db623ae85076f Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sat, 17 Jul 2021 17:58:03 +0200 Subject: ndp: Fix calculation of length for DNS Search List option (31) Signed-off-by: Stefano Brivio --- ndp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ndp.c b/ndp.c index a7360aa..8f69a64 100644 --- a/ndp.c +++ b/ndp.c @@ -127,7 +127,7 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len) len += strlen(c->dns_search[n].n) + 2; if (len) { *p++ = 31; /* DNSSL */ - *p++ = 2 + (len + 8 - 1) / 8; /* length */ + *p++ = (len + 8 - 1) / 8 + 1; /* length */ p += 2; /* reserved */ *(uint32_t *)p = htonl(60); /* lifetime */ p += 4; @@ -148,8 +148,8 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len) *(p++) = 0; } - memset(p, 0, len % 8); /* padding */ - p += len % 8; + memset(p, 0, 8 - len % 8); /* padding */ + p += 8 - len % 8; } *p++ = 1; /* source ll */ -- cgit v1.2.3