From 57bab4e1d3c5ffae8f7c698937d20a01222275c5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 13 Mar 2015 10:19:44 +0000 Subject: [PATCH] [tcpip] Fix dubious calculation of min_port Detected using sparse. Signed-off-by: Michael Brown --- src/net/tcpip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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++ ) {