mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-29 07:10:54 +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.
(cherry picked from commit 240cf62056
)
This commit is contained in:
parent
76efa271e6
commit
0a3e4cd10e
@ -827,14 +827,16 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) {
|
if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) {
|
||||||
pcb->state = ESTABLISHED;
|
pcb->state = ESTABLISHED;
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
|
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
|
#if LWIP_CALLBACK_API
|
||||||
LWIP_ASSERT("pcb->listener->accept != NULL",
|
LWIP_ASSERT("pcb->listener->accept != NULL",
|
||||||
(pcb->listener == NULL) || (pcb->listener->accept != NULL));
|
(pcb->listener == NULL) || (pcb->listener->accept != NULL));
|
||||||
|
#endif
|
||||||
if (pcb->listener == NULL) {
|
if (pcb->listener == NULL) {
|
||||||
/* listen pcb might be closed by now */
|
/* listen pcb might be closed by now */
|
||||||
err = ERR_VAL;
|
err = ERR_VAL;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */
|
||||||
{
|
{
|
||||||
tcp_backlog_accepted(pcb);
|
tcp_backlog_accepted(pcb);
|
||||||
/* Call the accept function. */
|
/* 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) \
|
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \
|
||||||
do { \
|
do { \
|
||||||
if((lpcb != NULL) && ((lpcb)->accept != NULL)) \
|
if((lpcb)->accept != NULL) \
|
||||||
(ret) = (lpcb)->accept((arg),(pcb),(err)); \
|
(ret) = (lpcb)->accept((arg),(pcb),(err)); \
|
||||||
else (ret) = ERR_ARG; \
|
else (ret) = ERR_ARG; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user