Skip to content

Commit

Permalink
Add missing option length checks in dhcpv6_handle_advert
Browse files Browse the repository at this point in the history
These might be redundant with checks elsewhere but it's better to be
safe.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
bwhacks committed Jan 28, 2016
1 parent f92e692 commit 78bc7d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dhcpv6.c
Expand Up @@ -813,7 +813,8 @@ static int dhcpv6_handle_advert(enum dhcpv6_msg orig, const int rc,
if (inf_max_rt >= DHCPV6_INF_MAX_RT_MIN &&
inf_max_rt <= DHCPV6_INF_MAX_RT_MAX)
cand.inf_max_rt = inf_max_rt;
} else if (otype == DHCPV6_OPT_IA_PD && request_prefix) {
} else if (otype == DHCPV6_OPT_IA_PD && request_prefix &&
olen >= -4 + sizeof(struct dhcpv6_ia_hdr)) {
struct dhcpv6_ia_hdr *h = (struct dhcpv6_ia_hdr*)&odata[-4];
uint8_t *oend = odata + olen, *d;
dhcpv6_for_each_option(&h[1], oend, otype, olen, d) {
Expand All @@ -823,7 +824,8 @@ static int dhcpv6_handle_advert(enum dhcpv6_msg orig, const int rc,
have_pd = p->prefix;
}
}
} else if (otype == DHCPV6_OPT_IA_NA) {
} else if (otype == DHCPV6_OPT_IA_NA &&
olen >= -4 + sizeof(struct dhcpv6_ia_hdr)) {
struct dhcpv6_ia_hdr *h = (struct dhcpv6_ia_hdr*)&odata[-4];
uint8_t *oend = odata + olen, *d;
dhcpv6_for_each_option(&h[1], oend, otype, olen, d)
Expand Down

0 comments on commit 78bc7d9

Please sign in to comment.