Fixed bug #36167 tcp server crash when client closes (maximum window)

This commit is contained in:
Simon Goldschmidt 2014-04-08 21:26:27 +02:00
parent 035ecef8a5
commit 88a57dc98d
2 changed files with 13 additions and 2 deletions

View File

@ -100,6 +100,9 @@ HISTORY
++ Bugfixes:
2014-04-08: Simon Goldschmidt
* tcp.c: Fixed bug #36167 tcp server crash when client closes (maximum window)
2014-04-06: Simon Goldschmidt
* tcp_in.c: Fixed bug #36210 lwIP does not elicit an empty ACK when received
unacceptable ACK

View File

@ -650,12 +650,20 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
/* pcb->state LISTEN not allowed here */
LWIP_ASSERT("don't call tcp_recved for listen-pcbs",
pcb->state != LISTEN);
LWIP_ASSERT("tcp_recved: len would wrap rcv_wnd\n",
len <= TCPWND_MAX - pcb->rcv_wnd);
pcb->rcv_wnd += len;
if (pcb->rcv_wnd > TCP_WND) {
pcb->rcv_wnd = TCP_WND;
} else if(pcb->rcv_wnd == 0) {
/* rcv_wnd overflowed */
if ((pcb->state == CLOSE_WAIT) || (pcb->state == LAST_ACK)) {
/* In passive close, we allow this, since the FIN bit is added to rcv_wnd
by the stack itself, since it is not mandatory for an application
to call tcp_recved() for the FIN bit, but e.g. the netconn API does so. */
pcb->rcv_wnd = TCP_WND;
} else {
LWIP_ASSERT("tcp_recved: len wrapped rcv_wnd\n", 0);
}
}
wnd_inflation = tcp_update_rcv_ann_wnd(pcb);