Merged from trunk: tcp_abandon: call tcp_rst before freeing the pcb to prevent copying addresses and ports to local variables

This commit is contained in:
goldsimon 2011-12-14 21:49:47 +01:00
parent ef0a44c62d
commit f76488a841

View File

@ -350,8 +350,6 @@ void
tcp_abandon(struct tcp_pcb *pcb, int reset) tcp_abandon(struct tcp_pcb *pcb, int reset)
{ {
u32_t seqno, ackno; u32_t seqno, ackno;
u16_t remote_port, local_port;
ip_addr_t remote_ip, local_ip;
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
tcp_err_fn errf; tcp_err_fn errf;
#endif /* LWIP_CALLBACK_API */ #endif /* LWIP_CALLBACK_API */
@ -369,10 +367,6 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
} else { } else {
seqno = pcb->snd_nxt; seqno = pcb->snd_nxt;
ackno = pcb->rcv_nxt; ackno = pcb->rcv_nxt;
ip_addr_copy(local_ip, pcb->local_ip);
ip_addr_copy(remote_ip, pcb->remote_ip);
local_port = pcb->local_port;
remote_port = pcb->remote_port;
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
errf = pcb->errf; errf = pcb->errf;
#endif /* LWIP_CALLBACK_API */ #endif /* LWIP_CALLBACK_API */
@ -389,12 +383,12 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
tcp_segs_free(pcb->ooseq); tcp_segs_free(pcb->ooseq);
} }
#endif /* TCP_QUEUE_OOSEQ */ #endif /* TCP_QUEUE_OOSEQ */
memp_free(MEMP_TCP_PCB, pcb);
TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT);
if (reset) { if (reset) {
LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n")); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n"));
tcp_rst(seqno, ackno, &local_ip, &remote_ip, local_port, remote_port); tcp_rst(seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port);
} }
memp_free(MEMP_TCP_PCB, pcb);
TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT);
} }
} }