mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix(lwip): reject invalid DHCP MTU option values
Validate MTU from DHCP option 26 against RFC 2132 minimum (68 bytes) before applying to netif->mtu, preventing rogue DHCP servers from setting MTU to 0 or other dangerously low values that cause integer wraparound in IPv4 fragmentation.
This commit is contained in:
@@ -234,6 +234,9 @@ void dhcp_parse_extra_opts(struct dhcp *dhcp, uint8_t state, uint8_t option, uin
|
||||
NETIF_FOREACH(netif) {
|
||||
/* find the netif related to this dhcp */
|
||||
if (dhcp == netif_dhcp_data(netif)) {
|
||||
if (mtu < 68) { /* RFC 2132 requires MTU >= 68 */
|
||||
return;
|
||||
}
|
||||
if (mtu < netif->mtu) {
|
||||
netif->mtu = mtu;
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_parse_extra_opts(): Negotiated netif MTU is %d\n", netif->mtu));
|
||||
|
||||
Reference in New Issue
Block a user