tcp_in/ooseq: Fix incorrect segment trim when FIN moved

In case FIN flag was present in the *next* segment,
it's copied to the current *inseg* and thus it's length
needs to be adjusted, so the segment is trimmed correctly.
This commit is contained in:
xueyunfei
2023-02-15 11:25:33 +08:00
parent aee6b3ed0c
commit 9e62afffb4
+4 -1
View File
@@ -1539,9 +1539,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);