From b6b2c4c85786ce076b5702459ee760c532391878 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 28 Aug 2024 15:11:26 +0900 Subject: [PATCH] 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." --- src/dhcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dhcp.c b/src/dhcp.c index 85d2c56f..953c52cb 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -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) @@ -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)