mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-12 16:20:06 +00:00
* sunrpc/bindrsvprt.c (bindresvport): Wrap around to startport
in the loop if port is bigger than endport, initially set to ENDPORT. When changing startport, set endport and port appropriately.
This commit is contained in:
parent
24eb865839
commit
15a493c3b7
@ -1,3 +1,10 @@
|
||||
2005-11-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* sunrpc/bindrsvprt.c (bindresvport): Wrap around to startport
|
||||
in the loop if port is bigger than endport, initially set to
|
||||
ENDPORT. When changing startport, set endport and port
|
||||
appropriately.
|
||||
|
||||
2005-11-21 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* Makefile.in: Remove RCS ID line.
|
||||
|
@ -74,14 +74,13 @@ bindresvport (int sd, struct sockaddr_in *sin)
|
||||
int res = -1;
|
||||
|
||||
int nports = ENDPORT - startport + 1;
|
||||
int endport = ENDPORT;
|
||||
again:
|
||||
for (i = 0; i < nports; ++i)
|
||||
{
|
||||
sin->sin_port = htons (port++);
|
||||
if (port > ENDPORT)
|
||||
{
|
||||
port = startport;
|
||||
}
|
||||
if (port > endport)
|
||||
port = startport;
|
||||
res = __bind (sd, sin, sizeof (struct sockaddr_in));
|
||||
if (res >= 0 || errno != EADDRINUSE)
|
||||
break;
|
||||
@ -90,7 +89,9 @@ bindresvport (int sd, struct sockaddr_in *sin)
|
||||
if (i == nports && startport != LOWPORT)
|
||||
{
|
||||
startport = LOWPORT;
|
||||
endport = STARTPORT - 1;
|
||||
nports = STARTPORT - LOWPORT;
|
||||
port = LOWPORT + port % (STARTPORT - LOWPORT);
|
||||
goto again;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user