From aa5924187c04d664d19f3707a6e962cfecb1271b Mon Sep 17 00:00:00 2001 From: Adrian Bondrescu Date: Sun, 8 Jul 2012 21:04:00 +0300 Subject: [PATCH] If port 0 is provided for binding, bind the socket to the next free port from the pool. --- src/kernel/mptp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kernel/mptp.c b/src/kernel/mptp.c index 94c5263..a2ec2bc 100644 --- a/src/kernel/mptp.c +++ b/src/kernel/mptp.c @@ -97,6 +97,8 @@ static int mptp_bind(struct socket *sock, struct sockaddr *addr, int addr_len) log_debug("Bind received port=%u (network order)\n", mptp_addr->dests[0].port); port = ntohs(mptp_addr->dests[0].port); + if (port == 0) + port = get_next_free_port(); if (unlikely(port == 0 || port >= MAX_MPTP_PORT)) { log_error("Invalid value for sockaddr port (%u)\n", port); -- 2.20.1