Skip to content

Commit b6b2c4c

Browse files
committed
dhcp: get_option_uint32/16 only accept options with correct len
RFC8925 mentions "The client MUST ignore the IPv6-Only Preferred option if the length field value is not 4."
1 parent ab5ec18 commit b6b2c4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/dhcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ get_option_uint32(struct dhcpcd_ctx *ctx,
304304
uint32_t d;
305305

306306
p = get_option(ctx, bootp, bootp_len, option, &len);
307-
if (!p || len < (ssize_t)sizeof(d))
307+
if (!p || len != (ssize_t)sizeof(d))
308308
return -1;
309309
memcpy(&d, p, sizeof(d));
310310
if (i)
@@ -321,7 +321,7 @@ get_option_uint16(struct dhcpcd_ctx *ctx,
321321
uint16_t d;
322322

323323
p = get_option(ctx, bootp, bootp_len, option, &len);
324-
if (!p || len < (ssize_t)sizeof(d))
324+
if (!p || len != (ssize_t)sizeof(d))
325325
return -1;
326326
memcpy(&d, p, sizeof(d));
327327
if (i)

0 commit comments

Comments
 (0)