mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-12 13:13:21 +00:00
tcp: fix accept event on closed listening PCBs
If LWIP_CALLBACK_API is not defined, but TCP_LISTEN_BACKLOG is, then the LWIP_EVENT_ACCEPT TCP event may be triggered for closed listening sockets. This case is just as disastrous for the event API as it is for the callback API, as there is no way for the event hook to tell whether the listening PCB is still around. Add the same protection against this case for TCP_LISTEN_BACKLOG as was already in place for LWIP_CALLBACK_API. Also remove one NULL check for LWIP_CALLBACK_API that had already become redundant for all callers, making the TCP_EVENT_ACCEPT code for that callback wrapper more in line with the rest of the wrappers.
This commit is contained in:
parent
b9e66bfcfb
commit
240cf62056
@ -827,14 +827,16 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) {
|
||||
pcb->state = ESTABLISHED;
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
|
||||
#if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG
|
||||
#if LWIP_CALLBACK_API
|
||||
LWIP_ASSERT("pcb->listener->accept != NULL",
|
||||
(pcb->listener == NULL) || (pcb->listener->accept != NULL));
|
||||
#endif
|
||||
if (pcb->listener == NULL) {
|
||||
/* listen pcb might be closed by now */
|
||||
err = ERR_VAL;
|
||||
} else
|
||||
#endif
|
||||
#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */
|
||||
{
|
||||
tcp_backlog_accepted(pcb);
|
||||
/* Call the accept function. */
|
||||
|
@ -179,7 +179,7 @@ err_t tcp_process_refused_data(struct tcp_pcb *pcb);
|
||||
|
||||
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \
|
||||
do { \
|
||||
if((lpcb != NULL) && ((lpcb)->accept != NULL)) \
|
||||
if((lpcb)->accept != NULL) \
|
||||
(ret) = (lpcb)->accept((arg),(pcb),(err)); \
|
||||
else (ret) = ERR_ARG; \
|
||||
} while (0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user