diff mbox series

busybox: udhcpc, allow zero length dhcp options

Message ID 87y2eodk3n.fsf@husum.ptp
State Superseded
Delegated to: Hauke Mehrtens
Headers show
Series busybox: udhcpc, allow zero length dhcp options | expand

Commit Message

Russell Senior March 16, 2021, 12:21 a.m. UTC
Discovered that the DHCP server on a TrendNet router (unknown model)
provides a zero-length option 12 (Host Name) in the DHCP ACK message. This
has the effect of causing udhcpc to drop the rest of the options, including
option 51 (IP Address Lease Time), 3 (Router), and 6 (Domain Name Server),
most importantly leaving the OpenWrt device with no default gateway.

The TrendNet behavior violates RFC 2132, which in Section 3.14 declares that
option 12 has a miniumum length of 1 octet. It is perhaps not a cosmic coincidence
that I found this behavior on Pi Day.

This patch allows zero length options without bailing out, by simply
skipping them.

[patch also sent upstream]


Signed-off-by: Russell Senior <russell@personaltelco.net>
---
 .../205-udhcpc_allow_zero_length_options.patch  | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch
diff mbox series

Patch

diff --git a/package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch b/package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch
new file mode 100644
index 0000000000..ecb18530e2
--- /dev/null
+++ b/package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch
@@ -0,0 +1,17 @@ 
+--- a/networking/udhcp/common.c
++++ b/networking/udhcp/common.c
+@@ -277,8 +277,12 @@ uint8_t* FAST_FUNC udhcp_scan_options(st
+ 			goto complain; /* complain and return NULL */
+ 		len = 2 + scan_state->optionptr[OPT_LEN];
+ 		scan_state->rem -= len;
+-		/* So far no valid option with length 0 known. */
+-		if (scan_state->rem < 0 || scan_state->optionptr[OPT_LEN] == 0)
++		/* skip any options with zero length */
++		if (scan_state->optionptr[OPT_LEN] == 0) {
++			scan_state->optionptr += OPT_LEN;
++			continue;
++		}
++		if (scan_state->rem < 0)
+ 			goto complain; /* complain and return NULL */
+ 
+ 		if (scan_state->optionptr[OPT_CODE] == DHCP_OPTION_OVERLOAD) {