From ece2c512d596d3f9ed326d86c6c9520b84f234bb Mon Sep 17 00:00:00 2001 From: Marian Cingel Date: Tue, 10 Nov 2026 00:19:50 +0000 Subject: [PATCH] dhcp: don't write past the end of options_list[] Otherwise each DHCP offer (option 53 - message type) corrupts the global variable 'bmacaddr', placed by the linker in my build after options_list. Subsequent REQUESTs are then sent to MAC 00:00:00:00:00:00 instead of broadcast and no lease is obtained. Seen on iMX7Sabre (ARMv7, MUSL 1.2.6, GCC 16.2.1, static build) --- toys/pending/dhcp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c index 2c77720c..adf76c5c 100644 --- a/toys/pending/dhcp.c +++ b/toys/pending/dhcp.c @@ -1099,6 +1099,11 @@ static uint8_t dhcpc_parseoptions(dhcpc_result_t *presult, uint8_t *optptr) break; } } + // Skip unknown options (e.g 0x35 msg type) instead of writing past the end of 'options_list' + if (count == size) { + optptr += optptr[1] + 2; + continue; + } msgopt_list[count].val = 0; msgopt_list[count].len = 0; switch (flag) { -- 2.39.5