mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-03 17:36:45 +00:00
ethernet_input: check for minimum packet length to prevent assertions from firing.
This commit is contained in:
parent
11b1c9f19f
commit
36c1750b8f
@ -1219,6 +1219,13 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
|||||||
struct eth_hdr* ethhdr;
|
struct eth_hdr* ethhdr;
|
||||||
u16_t type;
|
u16_t type;
|
||||||
|
|
||||||
|
if (p->tot_len <= SIZEOF_ETH_HDR) {
|
||||||
|
/* a packet with only an ethernet header (or less) is not valid */
|
||||||
|
ETHARP_STATS_INC(etharp.proterr);
|
||||||
|
ETHARP_STATS_INC(etharp.drop);
|
||||||
|
goto free_and_return;
|
||||||
|
}
|
||||||
|
|
||||||
/* points to packet payload, which starts with an Ethernet header */
|
/* points to packet payload, which starts with an Ethernet header */
|
||||||
ethhdr = (struct eth_hdr *)p->payload;
|
ethhdr = (struct eth_hdr *)p->payload;
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE,
|
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE,
|
||||||
@ -1232,6 +1239,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
|
|||||||
type = ethhdr->type;
|
type = ethhdr->type;
|
||||||
#if ETHARP_SUPPORT_VLAN
|
#if ETHARP_SUPPORT_VLAN
|
||||||
if (type == PP_HTONS(ETHTYPE_VLAN)) {
|
if (type == PP_HTONS(ETHTYPE_VLAN)) {
|
||||||
|
/* @todo: check for minimum packet length */
|
||||||
struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr*)(((char*)ethhdr) + SIZEOF_ETH_HDR);
|
struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr*)(((char*)ethhdr) + SIZEOF_ETH_HDR);
|
||||||
#ifdef ETHARP_VLAN_CHECK /* if not, allow all VLANs */
|
#ifdef ETHARP_VLAN_CHECK /* if not, allow all VLANs */
|
||||||
if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) {
|
if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user