From b7d7559cc9b02bf282017829c895465f311943de Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sun, 18 Oct 2009 08:30:44 +0000 Subject: [PATCH] Fixed bug #27215: TCP sent() callback gives leadin and trailing 1 byte len (SYN/FIN) --- CHANGELOG | 4 ++++ src/core/tcp_in.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4c99bfcd..7e5b30a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -43,6 +43,10 @@ HISTORY ++ Bugfixes: + 2009-10-18: Simon Goldschmidt + * tcp_in.c: Fixed bug #27215: TCP sent() callback gives leadin and + trailing 1 byte len (SYN/FIN) + 2009-10-16: Simon Goldschmidt * tcp_out.c: Fixed bug #27315: zero window probe and FIN diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 1903e7a8..2017c322 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -96,6 +96,7 @@ tcp_input(struct pbuf *p, struct netif *inp) struct tcp_pcb_listen *lpcb; u8_t hdrlen; err_t err; + u8_t old_state; PERF_START; @@ -288,7 +289,7 @@ tcp_input(struct pbuf *p, struct netif *inp) return; } } - + old_state = pcb->state; tcp_input_pcb = pcb; err = tcp_process(pcb); tcp_input_pcb = NULL; @@ -314,7 +315,11 @@ tcp_input(struct pbuf *p, struct netif *inp) called when new send buffer space is available, we call it now. */ if (pcb->acked > 0) { - TCP_EVENT_SENT(pcb, pcb->acked, err); + /* Prevent ACK for SYN or FIN to generate a sent event */ + if ((pcb->acked != 1) || ((old_state != SYN_RCVD) && + (pcb->state != FIN_WAIT_2) && (pcb->state != TIME_WAIT))) { + TCP_EVENT_SENT(pcb, pcb->acked, err); + } } if (recv_data != NULL) {