]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-bindresvport2.patch
This commit was manufactured by cvs2git to create branch 'AC-branch'.
[packages/glibc.git] / glibc-bindresvport2.patch
1 2005-11-21  Jakub Jelinek  <jakub@redhat.com>
2
3         * sunrpc/bindrsvprt.c (bindresvport): Wrap around to startport
4         in the loop if port is bigger than endport, initially set to
5         ENDPORT.  When changing startport, set endport and port
6         appropriately.
7
8 --- libc/sunrpc/bindrsvprt.c    23 May 2005 19:03:43 -0000      1.11
9 +++ libc/sunrpc/bindrsvprt.c    22 Nov 2005 04:39:05 -0000      1.12
10 @@ -74,14 +74,13 @@ bindresvport (int sd, struct sockaddr_in
11    int res = -1;
12  
13    int nports = ENDPORT - startport + 1;
14 +  int endport = ENDPORT;
15   again:
16    for (i = 0; i < nports; ++i)
17      {
18        sin->sin_port = htons (port++);
19 -      if (port > ENDPORT)
20 -       {
21 -         port = startport;
22 -       }
23 +      if (port > endport)
24 +       port = startport;
25        res = __bind (sd, sin, sizeof (struct sockaddr_in));
26        if (res >= 0 || errno != EADDRINUSE)
27         break;
28 @@ -90,7 +89,9 @@ bindresvport (int sd, struct sockaddr_in
29    if (i == nports && startport != LOWPORT)
30      {
31        startport = LOWPORT;
32 +      endport = STARTPORT - 1;
33        nports = STARTPORT - LOWPORT;
34 +      port = LOWPORT + port % (STARTPORT - LOWPORT);
35        goto again;
36      }
37  
This page took 0.03455 seconds and 3 git commands to generate.