X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fra.c;h=2d442f6a8bfbab096a2654317bd08fa60f113118;hp=dcb3e0f0fb40e9ee9281979ebf23435e52821254;hb=8a8005f7ca8973702b36e711993bfff89ca9600c;hpb=19c64c524614ea7fdbcedcc50d6980f096ccadb9 diff --git a/src/ra.c b/src/ra.c index dcb3e0f..2d442f6 100644 --- a/src/ra.c +++ b/src/ra.c @@ -424,14 +424,17 @@ bool ra_process(void) while (buf < end) { int len = dn_expand(buf, end, buf, (char*)entry->auxtarget, 256); - if (len > 0) { - buf = &buf[len]; - entry->auxlen = strlen((char*)entry->auxtarget); - changed |= odhcp6c_update_entry(STATE_RA_SEARCH, entry, 0, true); - entry->auxlen = 0; - } else { + if (len < 1) break; - } + + buf = &buf[len]; + entry->auxlen = strlen((char*)entry->auxtarget); + + if (entry->auxlen == 0) + continue; + + changed |= odhcp6c_update_entry(STATE_RA_SEARCH, entry, 0, true); + entry->auxlen = 0; } } } @@ -441,8 +444,9 @@ bool ra_process(void) size_t ra_dns_len; uint8_t *start = odhcp6c_get_state(states[i], &ra_dns_len); for (struct odhcp6c_entry *c = (struct odhcp6c_entry*)start; - (uint8_t*)c < &start[ra_dns_len] && &c->auxtarget[c->auxlen] <= &start[ra_dns_len]; - c = (struct odhcp6c_entry*)(&c->auxtarget[c->auxlen])) + (uint8_t*)c < &start[ra_dns_len] && + (uint8_t*)odhcp6c_next_entry(c) <= &start[ra_dns_len]; + c = odhcp6c_next_entry(c)) if (IN6_ARE_ADDR_EQUAL(&c->router, &from.sin6_addr) && c->valid > router_valid) c->valid = router_valid;