]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Add sanity checks for NDP and MTU parameters from RAs
authorSteven Barth <steven@midlink.org>
Thu, 13 Jun 2013 06:36:31 +0000 (08:36 +0200)
committerSteven Barth <steven@midlink.org>
Thu, 13 Jun 2013 06:36:31 +0000 (08:36 +0200)
src/ra.c

index 1b2f7294a0b4f27b2905a7613ccd10709a1f81d2..b1526aed6ccacaba046b10072fd8e8887628fb29 100644 (file)
--- a/src/ra.c
+++ b/src/ra.c
@@ -235,10 +235,10 @@ bool ra_process(void)
                odhcp6c_update_entry(STATE_RA_ROUTE, &entry);
 
                // Parse ND parameters
-               if (adv->nd_ra_reachable)
+               if (ntohl(adv->nd_ra_reachable) <= 3600000)
                        update_proc("neigh", "base_reachable_time_ms", ntohl(adv->nd_ra_reachable));
 
-               if (adv->nd_ra_retransmit)
+               if (ntohl(adv->nd_ra_retransmit) <= 60000)
                        update_proc("neigh", "retrans_time_ms", ntohl(adv->nd_ra_retransmit));
 
 
@@ -247,7 +247,8 @@ bool ra_process(void)
                icmpv6_for_each_option(opt, &adv[1], &buf[len]) {
                        if (opt->type == ND_OPT_MTU) {
                                uint32_t *mtu = (uint32_t*)&opt->data[2];
-                               update_proc("conf", "mtu", ntohl(*mtu));
+                               if (ntohl(*mtu) >= 1280 && ntohl(*mtu) <= 65535)
+                                       update_proc("conf", "mtu", ntohl(*mtu));
                        } else if (opt->type == ND_OPT_ROUTE_INFORMATION && opt->len <= 3) {
                                entry.router = from.sin6_addr;
                                entry.target = any;