Skip to content
Snippets Groups Projects
Commit 49f06efd authored by Gunar Schorcht's avatar Gunar Schorcht
Browse files

cpu/esp8266: fix pbuf length check in esp_wifi

When the size of a received frame is checked, always the total length should be used instead of the length of the first lwIP pbuf in the pbuf chain. Otherwise, the check that the length does not exceed ETHERNET_MAX_LEN will always be true since the maximum size of one lwIP pbuf in a pbuf chain is 512 bytes.
parent 88c65aff
No related branches found
No related tags found
No related merge requests found
...@@ -185,9 +185,9 @@ void IRAM _esp_wifi_recv_cb(struct pbuf *pb, struct netif *netif) ...@@ -185,9 +185,9 @@ void IRAM _esp_wifi_recv_cb(struct pbuf *pb, struct netif *netif)
critical_enter(); critical_enter();
/* first, check packet buffer for the minimum packet size */ /* first, check packet buffer for the minimum packet size */
if (pb->len < sizeof(ethernet_hdr_t)) { if (pb->tot_len < sizeof(ethernet_hdr_t)) {
ESP_WIFI_DEBUG("frame length is less than the size of an Ethernet" ESP_WIFI_DEBUG("frame length is less than the size of an Ethernet"
"header (%u < %u)", pb->len, sizeof(ethernet_hdr_t)); "header (%u < %u)", pb->tot_len, sizeof(ethernet_hdr_t));
pbuf_free(pb); pbuf_free(pb);
_in_esp_wifi_recv_cb = false; _in_esp_wifi_recv_cb = false;
critical_exit(); critical_exit();
...@@ -207,9 +207,9 @@ void IRAM _esp_wifi_recv_cb(struct pbuf *pb, struct netif *netif) ...@@ -207,9 +207,9 @@ void IRAM _esp_wifi_recv_cb(struct pbuf *pb, struct netif *netif)
} }
/* check whether packet buffer fits into receive buffer */ /* check whether packet buffer fits into receive buffer */
if (pb->len > ETHERNET_MAX_LEN) { if (pb->tot_len > ETHERNET_MAX_LEN) {
ESP_WIFI_DEBUG("frame length is greater than the maximum size of an " ESP_WIFI_DEBUG("frame length is greater than the maximum size of an "
"Ethernet frame (%u > %u)", pb->len, ETHERNET_MAX_LEN); "Ethernet frame (%u > %u)", pb->tot_len, ETHERNET_MAX_LEN);
pbuf_free(pb); pbuf_free(pb);
_in_esp_wifi_recv_cb = false; _in_esp_wifi_recv_cb = false;
critical_exit(); critical_exit();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment