mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-09-06 01:00:09 +00:00
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:
+4
-1
@@ -1539,9 +1539,12 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
if (next &&
|
if (next &&
|
||||||
TCP_SEQ_GT(seqno + tcplen,
|
TCP_SEQ_GT(seqno + tcplen,
|
||||||
next->tcphdr->seqno)) {
|
next->tcphdr->seqno)) {
|
||||||
/* inseg cannot have FIN here (already processed above) */
|
|
||||||
inseg.len = (u16_t)(next->tcphdr->seqno - seqno);
|
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) {
|
if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) {
|
||||||
|
#endif
|
||||||
inseg.len -= 1;
|
inseg.len -= 1;
|
||||||
}
|
}
|
||||||
pbuf_realloc(inseg.p, inseg.len);
|
pbuf_realloc(inseg.p, inseg.len);
|
||||||
|
|||||||
Reference in New Issue
Block a user