From: Michael Brown Date: Thu, 10 Jul 2008 03:21:10 +0000 (+0100) Subject: [udp] Avoid reusing auto-allocated ports after connection close. X-Git-Tag: v0.9.4~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21e9e801e268302cf2705d9b0e658f9896963fe0;p=thirdparty%2Fipxe.git [udp] Avoid reusing auto-allocated ports after connection close. This duplicates a fix made to tcp.c in commit d5735c631cf26d8e1bcf7b5e635623b52d6b48aa. --- diff --git a/src/net/udp.c b/src/net/udp.c index 8df76a445..407ea14db 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -55,11 +55,12 @@ struct tcpip_protocol udp_protocol; */ static int udp_bind ( struct udp_connection *udp ) { struct udp_connection *existing; - static uint16_t try_port = 1024; + static uint16_t try_port = 1023; /* If no port specified, find the first available port */ if ( ! udp->local.st_port ) { - for ( ; try_port ; try_port++ ) { + while ( try_port ) { + try_port++; if ( try_port < 1024 ) continue; udp->local.st_port = htons ( try_port );