Skip to content

Commit

Permalink
dhcp: get_option_uint32/16 only accept options with correct len
Browse files Browse the repository at this point in the history
RFC8925 mentions "The client MUST ignore the IPv6-Only Preferred option
if the length field value is not 4."
  • Loading branch information
taoyl-g committed Aug 28, 2024
1 parent ab5ec18 commit b6b2c4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ get_option_uint32(struct dhcpcd_ctx *ctx,
uint32_t d;

p = get_option(ctx, bootp, bootp_len, option, &len);
if (!p || len < (ssize_t)sizeof(d))
if (!p || len != (ssize_t)sizeof(d))
return -1;
memcpy(&d, p, sizeof(d));
if (i)
Expand All @@ -321,7 +321,7 @@ get_option_uint16(struct dhcpcd_ctx *ctx,
uint16_t d;

p = get_option(ctx, bootp, bootp_len, option, &len);
if (!p || len < (ssize_t)sizeof(d))
if (!p || len != (ssize_t)sizeof(d))
return -1;
memcpy(&d, p, sizeof(d));
if (i)
Expand Down

0 comments on commit b6b2c4c

Please sign in to comment.