Fix off-by-one error in enumatering UDP ports in the port_range. Make the error message a little more useful.

This commit is contained in:
Mike Brady
2017-04-16 17:09:59 +01:00
parent 8a891058d7
commit 555c0c738b
+2 -2
View File
@@ -562,13 +562,13 @@ static int bind_port(int ip_family, const char *self_ip_address, uint32_t scope_
#endif
} while ((ret < 0) && (errno == EADDRINUSE) && (desired_port != 0) &&
(desired_port++ < config.udp_port_base + config.udp_port_range));
(++desired_port < config.udp_port_base + config.udp_port_range));
// debug(1,"UDP port chosen: %d.",desired_port);
if (ret < 0) {
close(local_socket);
die("error: could not bind a UDP port!");
die("error: could not bind a UDP port! Check the udp_port_range is large enough (>= 10) or check for restrictive firewall settings or a bad router!");
}
int sport;