From 8e23b8d903e8fb98b2f59f258ea0060eafedecd9 Mon Sep 17 00:00:00 2001 From: Matthias Hofmann Date: Mon, 4 Jun 2018 16:28:40 +0200 Subject: [PATCH] Correct UDP rebind check. Signed-off-by: Simon Goldschmidt --- src/core/udp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/udp.c b/src/core/udp.c index a9fcf679..71e345bc 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -984,8 +984,9 @@ udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) { /* port matches that of PCB in list and REUSEADDR not set -> reject */ if ((ipcb->local_port == port) && - /* IP address matches? */ - ip_addr_cmp(&ipcb->local_ip, ipaddr)) { + /* IP address matches or any IP used? */ + (ip_addr_cmp(&ipcb->local_ip, ipaddr) || ip_addr_isany(ipaddr) || + ip_addr_isany(&ipcb->local_ip))) { /* other PCB already binds to this local IP and port */ LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %"U16_F" already bound by another pcb\n", port));