Skip to content

(built-in ip stack) DHCP NTP option parsing gotcha #3399

@washley

Description

@washley

The below is in regards to the built-in tcp/ip stack.

The MG_TCPIP_EV_DHCP_SNTP event won't fire when the DHCP response contains more than one NTP server. The parsing code requires exactly length 4 (a single address), but this can be a list with more than one.

As long as you are OK with only accepting the first address, the fix is pretty simple

-    } else if (ifp->enable_req_sntp && p[0] == 42 && p[1] == sizeof(sntp) &&
+    } else if (ifp->enable_req_sntp && p[0] == 42 && p[1] >= sizeof(sntp) &&

It looks like parsing of the DHCP option has the same problem, but my DHCP only hands out a single address there so I haven't run into it. I suggest that both are either fixed (or not) together.

Environment

  • mongoose version: HEAD as of 1/9/26
  • Compiler/IDE and SDK: Pico SDK 2.2.0
  • Target hardware/board: pico2_w
  • Connectivity chip/module: pico
  • Target RTOS/OS (if applicable): N/A

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions