- size_t len, cmplen = offsetof(struct odhcp6c_entry, target) + new->length / 8;
- struct odhcp6c_entry *start = odhcp6c_get_state(state, &len);
- struct odhcp6c_entry *x = NULL;
-
- for (struct odhcp6c_entry *c = start; !x && c < &start[len/sizeof(*c)]; ++c)
- if (!memcmp(c, new, cmplen))
+ size_t len, cmplen = offsetof(struct odhcp6c_entry, target) + ((new->length + 7) / 8);
+ uint8_t *start = odhcp6c_get_state(state, &len);
+
+ for (struct odhcp6c_entry *c = (struct odhcp6c_entry*)start;
+ (uint8_t*)c < &start[len] &&
+ (uint8_t*)odhcp6c_next_entry(c) <= &start[len];
+ c = odhcp6c_next_entry(c))
+ if (!memcmp(c, new, cmplen) && !memcmp(c->auxtarget, new->auxtarget, new->auxlen))