mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-28 02:57:05 +08:00
fix bug #21699 (segment leak in ooseq): add assert that all segment lists are empty in tcp_pcb_remove before setting pcb to CLOSED state; don't directly set CLOSED state from LAST_ACK in tcp_process
This commit is contained in:
@@ -1138,7 +1138,16 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
|
||||
pcb->flags & TF_ACK_DELAY) {
|
||||
pcb->flags |= TF_ACK_NOW;
|
||||
tcp_output(pcb);
|
||||
}
|
||||
}
|
||||
|
||||
if (pcb->state != LISTEN) {
|
||||
LWIP_ASSERT("unsent segments leaking", pcb->unsent == NULL);
|
||||
LWIP_ASSERT("unacked segments leaking", pcb->unacked == NULL);
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
LWIP_ASSERT("ooseq segments leaking", pcb->ooseq == NULL);
|
||||
#endif /* TCP_QUEUE_OOSEQ */
|
||||
}
|
||||
|
||||
pcb->state = CLOSED;
|
||||
|
||||
LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane());
|
||||
|
||||
@@ -651,7 +651,7 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
tcp_receive(pcb);
|
||||
if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
|
||||
pcb->state = CLOSED;
|
||||
/* bugfix #21699: don't set pcb->state to CLOSED here or we risk leaking segments */
|
||||
recv_flags = TF_CLOSED;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user