]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tcpip] Fix dubious calculation of min_port
authorMichael Brown <mcb30@ipxe.org>
Fri, 13 Mar 2015 10:19:44 +0000 (10:19 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 13 Mar 2015 10:19:44 +0000 (10:19 +0000)
Detected using sparse.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/tcpip.c

index 261da5822de9e867abb6e1afe91aeb28101ba697..5ad982fd165086413c952a87410457f308865b2f 100644 (file)
@@ -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++ ) {