]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[IPV6]: Fix infinite loop in udp_v6_get_port().
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Tue, 4 Oct 2005 20:00:39 +0000 (13:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 4 Oct 2005 20:00:39 +0000 (13:00 -0700)
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/udp.c

index e4cad11f284ab9d2776070c729811d684df4e027..bf9519341fd30ad28a0b9652d09bcd7628765dc4 100644 (file)
@@ -99,7 +99,7 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
                next:;
                }
                result = best;
-               for(;; result += UDP_HTABLE_SIZE) {
+               for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) {
                        if (result > sysctl_local_port_range[1])
                                result = sysctl_local_port_range[0]
                                        + ((result - sysctl_local_port_range[0]) &
@@ -107,6 +107,8 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
                        if (!udp_lport_inuse(result))
                                break;
                }
+               if (i >= (1 << 16) / UDP_HTABLE_SIZE)
+                       goto fail;
 gotit:
                udp_port_rover = snum = result;
        } else {