fixed bug #34072: UDP broadcast is received from wrong UDP pcb if udp port matches

This commit is contained in:
Simon Goldschmidt 2011-09-09 22:25:59 +02:00 committed by goldsimon
parent 378bed8a03
commit 72e2d16f14
2 changed files with 19 additions and 11 deletions

View File

@ -27,6 +27,10 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2011-09-09: Simon Goldschmidt
* udp.c: fixed bug #34072: UDP broadcast is received from wrong UDP pcb if
udp port matches
2011-09-03: Simon Goldschmidt 2011-09-03: Simon Goldschmidt
* tcp_in.c: fixed bug #33952 PUSH flag in incoming packet is lost when packet * tcp_in.c: fixed bug #33952 PUSH flag in incoming packet is lost when packet
is aggregated and sent to application is aggregated and sent to application

View File

@ -171,22 +171,26 @@ udp_input(struct pbuf *p, struct netif *inp)
ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip), pcb->remote_port)); ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip), pcb->remote_port));
/* compare PCB local addr+port to UDP destination addr+port */ /* compare PCB local addr+port to UDP destination addr+port */
if ((pcb->local_port == dest) && if (pcb->local_port == dest) {
((!broadcast && ip_addr_isany(&pcb->local_ip)) || if (
(!broadcast && ip_addr_isany(&pcb->local_ip)) ||
ip_addr_cmp(&(pcb->local_ip), &current_iphdr_dest) || ip_addr_cmp(&(pcb->local_ip), &current_iphdr_dest) ||
#if LWIP_IGMP #if LWIP_IGMP
ip_addr_ismulticast(&current_iphdr_dest) || ip_addr_ismulticast(&current_iphdr_dest) ||
#endif /* LWIP_IGMP */ #endif /* LWIP_IGMP */
#if IP_SOF_BROADCAST_RECV #if IP_SOF_BROADCAST_RECV
(broadcast && (pcb->so_options & SOF_BROADCAST)))) { (broadcast && (pcb->so_options & SOF_BROADCAST) &&
#else /* IP_SOF_BROADCAST_RECV */ ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask))) {
(broadcast))) { #else /* IP_SOF_BROADCAST_RECV */
#endif /* IP_SOF_BROADCAST_RECV */ (broadcast &&
local_match = 1; ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask))) {
if ((uncon_pcb == NULL) && #endif /* IP_SOF_BROADCAST_RECV */
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { local_match = 1;
/* the first unconnected matching PCB */ if ((uncon_pcb == NULL) &&
uncon_pcb = pcb; ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {
/* the first unconnected matching PCB */
uncon_pcb = pcb;
}
} }
} }
/* compare PCB remote addr+port to UDP source addr+port */ /* compare PCB remote addr+port to UDP source addr+port */