Commit 9d544655 authored by Robert Lubos's avatar Robert Lubos Committed by Benjamin Cabé
Browse files

net: dhcpv4: client: Handle Pad option



Pad option (option code 0) can be present in between other options for
alignment. The option has a fixed 1-byte length (i. e. no length field),
therefore it did not fall under the common processing code for
unrecognized options (which include the length field at the second
byte). Therefore, not processing this option explicitly could disturb
other options processing, as the parser would wrongly interpret the next
option code as the length field. This commit adds Pad option handling to
fix the issue.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent f4408c08
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -979,6 +979,13 @@ static bool dhcpv4_parse_options(struct net_pkt *pkt,
			goto end;
		}

		if (type == DHCPV4_OPTIONS_PAD) {
			/* Pad option has a fixed 1-byte length and should be
			 * ignored.
			 */
			continue;
		}

		if (net_pkt_read_u8(pkt, &length)) {
			NET_ERR("option parsing, bad length");
			return false;
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ struct dhcp_msg {
#define DHCPV4_SERVER_PORT	67
#define DHCPV4_CLIENT_PORT	68

#define DHCPV4_OPTIONS_PAD		0
#define DHCPV4_OPTIONS_SUBNET_MASK	1
#define DHCPV4_OPTIONS_ROUTER		3
#define DHCPV4_OPTIONS_DNS_SERVER	6