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:
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
* tcp_in.c: fixed bug #33952 PUSH flag in incoming packet is lost when packet
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));
/* compare PCB local addr+port to UDP destination addr+port */
if ((pcb->local_port == dest) &&
((!broadcast && ip_addr_isany(&pcb->local_ip)) ||
if (pcb->local_port == dest) {
if (
(!broadcast && ip_addr_isany(&pcb->local_ip)) ||
ip_addr_cmp(&(pcb->local_ip), &current_iphdr_dest) ||
#if LWIP_IGMP
ip_addr_ismulticast(&current_iphdr_dest) ||
#endif /* LWIP_IGMP */
#if IP_SOF_BROADCAST_RECV
(broadcast && (pcb->so_options & SOF_BROADCAST)))) {
#else /* IP_SOF_BROADCAST_RECV */
(broadcast))) {
(broadcast && (pcb->so_options & SOF_BROADCAST) &&
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask))) {
#else /* IP_SOF_BROADCAST_RECV */
(broadcast &&
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask))) {
#endif /* IP_SOF_BROADCAST_RECV */
local_match = 1;
if ((uncon_pcb == NULL) &&
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {
/* the first unconnected matching PCB */
uncon_pcb = pcb;
local_match = 1;
if ((uncon_pcb == NULL) &&
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {
/* the first unconnected matching PCB */
uncon_pcb = pcb;
}
}
}
/* compare PCB remote addr+port to UDP source addr+port */