VFS LwIP: do not free TCP PCBs on error

The VFS LwIP plugin is page-faulting on connect error because the LwIP
library frees a failed TCP protocol control block before calling the
error callback, and then the VFS plugin dereferences the PCB to free it
a second time. This problem was caused by a failure to follow
documentation during a transition from a C callback to a C++ method.

Fix #2972
This commit is contained in:
Ehmry - 2018-09-10 13:57:52 +02:00 committed by Christian Helmuth
parent 770fc77584
commit 98380cebda
2 changed files with 4 additions and 7 deletions

View File

@ -61,6 +61,7 @@ typedef uintptr_t mem_ptr_t;
#ifndef LWIP_NO_INTTYPES_H
#define LWIP_NO_INTTYPES_H 1
/* Define (sn)printf formatters */
#define X8_F "02x"
#define U16_F "u" // we don't have hu
#define S16_F "d" // we don't have hd
#define X16_F "x" // we don't have hx

View File

@ -1092,17 +1092,13 @@ class Lwip::Tcp_socket_dir final :
*
* Triggered by error callback, usually
* just by an aborted connection.
* The corresponding pcb is already freed
* when this callback is called!
*/
void error()
{
state = CLOSED;
/* the PCB is expired now */
if (_pcb) {
tcp_arg(_pcb, NULL);
tcp_close(_pcb);
_pcb = NULL;
}
_pcb = NULL;
/* churn the application */
handle_io(~0U);