Skip to content

Commit

Permalink
tcp_in/ooseq: Fix incorrect segment trim when FIN moved
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
freakyxue committed Mar 14, 2023
1 parent 53a6e01 commit 6bb132e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/tcp_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,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);
Expand Down

0 comments on commit 6bb132e

Please sign in to comment.