dhcpv6: Subtract option length before returning one option
dhcpv6_opt() needs to subtract option length _before_ returning, so that callers can conveniently pass the remaining length on subsequent calls. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
ad60ab1b37
commit
49c766398d
1 changed files with 2 additions and 1 deletions
3
dhcpv6.c
3
dhcpv6.c
|
@ -277,10 +277,11 @@ static struct opt_hdr *dhcpv6_opt(struct opt_hdr *o, uint16_t type, size_t *len)
|
||||||
if (ntohs(o->l) > *len)
|
if (ntohs(o->l) > *len)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
*len -= ntohs(o->l) + sizeof(struct opt_hdr);
|
||||||
|
|
||||||
if (o->t == type)
|
if (o->t == type)
|
||||||
return o;
|
return o;
|
||||||
|
|
||||||
*len -= ntohs(o->l) + sizeof(struct opt_hdr);
|
|
||||||
o = (struct opt_hdr *)((uint8_t *)(o + 1) + ntohs(o->l));
|
o = (struct opt_hdr *)((uint8_t *)(o + 1) + ntohs(o->l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue