fix(lwip): Trim to max packet size in dhcp server

This commit is contained in:
David Cermak
2026-04-30 21:25:28 +08:00
committed by David Čermák
parent c00874869b
commit 1d328aea61
+6 -1
View File
@@ -1230,7 +1230,7 @@ static void handle_dhcp(void *arg,
{ {
struct dhcps_t *dhcps = arg; struct dhcps_t *dhcps = arg;
struct dhcps_msg *pmsg_dhcps = NULL; struct dhcps_msg *pmsg_dhcps = NULL;
s16_t tlen, malloc_len; u16_t tlen, malloc_len;
u16_t i; u16_t i;
u16_t dhcps_msg_cnt = 0; u16_t dhcps_msg_cnt = 0;
u8_t *p_dhcps_msg = NULL; u8_t *p_dhcps_msg = NULL;
@@ -1245,6 +1245,11 @@ static void handle_dhcp(void *arg,
return; return;
} }
if (p->tot_len > 1500) {
pbuf_free(p);
return;
}
malloc_len = sizeof(struct dhcps_msg); malloc_len = sizeof(struct dhcps_msg);
#if DHCPS_DEBUG #if DHCPS_DEBUG
DHCPS_LOG("dhcps: handle_dhcp malloc_len=%d rx_len=%d", malloc_len, p->tot_len); DHCPS_LOG("dhcps: handle_dhcp malloc_len=%d rx_len=%d", malloc_len, p->tot_len);