From a1a9b0346bb2975b1dc33c572a969b0cb9158481 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Wed, 15 Feb 2023 11:25:33 +0800 Subject: [PATCH] tcp_in/ooseq: Fix incorrect segment trim when FIN moved 2.1.3-esp: 9e62afff tcp_in/ooseq: Fix incorrect segment trim when FIN moved --- src/core/tcp_in.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 913951d4..1268276d 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -1544,9 +1544,12 @@ tcp_receive(struct tcp_pcb *pcb) if (next && TCP_SEQ_GT(seqno + tcplen, next->tcphdr->seqno)) { - /* inseg cannot have FIN here (already processed above) */ inseg.len = (u16_t)(next->tcphdr->seqno - seqno); +#if ESP_LWIP + if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN || TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { +#else if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { +#endif inseg.len -= 1; } pbuf_realloc(inseg.p, inseg.len);