diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index 2ebe553ea19..c1c0db15ced 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -1136,7 +1136,7 @@ static void handle_dhcp(void *arg, { struct dhcps_t *dhcps = arg; struct dhcps_msg *pmsg_dhcps = NULL; - s16_t tlen, malloc_len; + u16_t tlen, malloc_len; u16_t i; u16_t dhcps_msg_cnt = 0; u8_t *p_dhcps_msg = NULL; @@ -1151,6 +1151,11 @@ static void handle_dhcp(void *arg, return; } + if (p->tot_len > 1500) { + pbuf_free(p); + return; + } + malloc_len = sizeof(struct dhcps_msg); #if DHCPS_DEBUG DHCPS_LOG("dhcps: handle_dhcp malloc_len=%d rx_len=%d", malloc_len, p->tot_len);