From: Michael Brown Date: Fri, 13 Mar 2015 10:19:44 +0000 (+0000) Subject: [tcpip] Fix dubious calculation of min_port X-Git-Tag: v1.20.1~900 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57bab4e1d3c5ffae8f7c698937d20a01222275c5;p=thirdparty%2Fipxe.git [tcpip] Fix dubious calculation of min_port Detected using sparse. Signed-off-by: Michael Brown --- diff --git a/src/net/tcpip.c b/src/net/tcpip.c index 261da5822..5ad982fd1 100644 --- a/src/net/tcpip.c +++ b/src/net/tcpip.c @@ -235,7 +235,7 @@ int tcpip_bind ( struct sockaddr_tcpip *st_local, /* Otherwise, find an available port in the range [1,1023] or * [1025,65535] as appropriate. */ - min_port = ( ( ( ! flags ) & TCPIP_BIND_PRIVILEGED ) + 1 ); + min_port = ( ( ( ~flags ) & TCPIP_BIND_PRIVILEGED ) + 1 ); max_port = ( ( flags & TCPIP_BIND_PRIVILEGED ) - 1 ); offset = random(); for ( i = 0 ; i <= max_port ; i++ ) {