Fixed bug #27315: zero window probe and FIN

This commit is contained in:
goldsimon 2009-10-16 21:07:48 +00:00
parent d8d8cf7e98
commit 502e89f4ad
2 changed files with 16 additions and 4 deletions

View File

@ -43,6 +43,9 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2009-10-16: Simon Goldschmidt
* tcp_out.c: Fixed bug #27315: zero window probe and FIN
2009-10-16: Simon Goldschmidt 2009-10-16: Simon Goldschmidt
* ip.c: Fixed bug #27390: Source IP check in ip_input() causes it to drop * ip.c: Fixed bug #27390: Source IP check in ip_input() causes it to drop
valid DHCP packets -> allow 0.0.0.0 as source address when LWIP_DHCP is valid DHCP packets -> allow 0.0.0.0 as source address when LWIP_DHCP is

View File

@ -926,6 +926,8 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
struct pbuf *p; struct pbuf *p;
struct tcp_hdr *tcphdr; struct tcp_hdr *tcphdr;
struct tcp_seg *seg; struct tcp_seg *seg;
u16_t len;
u8_t is_fin;
LWIP_DEBUGF(TCP_DEBUG, LWIP_DEBUGF(TCP_DEBUG,
("tcp_zero_window_probe: sending ZERO WINDOW probe to %" ("tcp_zero_window_probe: sending ZERO WINDOW probe to %"
@ -946,8 +948,10 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
if(seg == NULL) if(seg == NULL)
return; return;
p = pbuf_alloc(PBUF_IP, TCP_HLEN + 1, PBUF_RAM); is_fin = (TCPH_FLAGS(seg->tcphdr) & TCP_FIN) != 0;
len = is_fin ? TCP_HLEN : TCP_HLEN + 1;
p = pbuf_alloc(PBUF_IP, len, PBUF_RAM);
if(p == NULL) { if(p == NULL) {
LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: no memory for pbuf\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: no memory for pbuf\n"));
return; return;
@ -957,8 +961,13 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
tcphdr = tcp_output_set_header(pcb, p, 0, seg->tcphdr->seqno); tcphdr = tcp_output_set_header(pcb, p, 0, seg->tcphdr->seqno);
/* Copy in one byte from the head of the unacked queue */ if (is_fin) {
*((char *)p->payload + sizeof(struct tcp_hdr)) = *(char *)seg->dataptr; /* FIN segment, no data */
TCPH_FLAGS_SET(tcphdr, TCP_ACK | TCP_FIN);
} else {
/* Data segment, copy in one byte from the head of the unacked queue */
*((char *)p->payload + sizeof(struct tcp_hdr)) = *(char *)seg->dataptr;
}
#if CHECKSUM_GEN_TCP #if CHECKSUM_GEN_TCP
tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, tcphdr->chksum = inet_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip,