Browse Source

bindresvport() uses two static variables port and startport which are not

protected. It is not safe when in multithread circumstance.

bindresvport() select a port number from the range 512 to 1023, when in
multithread circumstance, the port may be 1024. So the static variables will be
protected.

Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
Reviewed-by: Carlos O'Donell <carlos@systemhalted.org>
hjl/global
Peng Haitao 14 years ago
committed by Carlos O'Donell
parent
commit
f6da27e536
  1. 5
      ChangeLog
  2. 18
      NEWS
  3. 11
      sunrpc/bindrsvprt.c

5
ChangeLog

@ -1,3 +1,8 @@
2012-11-19 Peng Haitao <penght@cn.fujitsu.com>
[BZ #13763]
* sunrpc/bindrsvprt.c: Add lock to protect static variable.
2012-11-19 Steve McIntyre <steve.mcintyre@linaro.org>
* sysdeps/generic/ldconfig.h (FLAG_AARCH64_LIB64): New macro.

18
NEWS

@ -12,15 +12,15 @@ Version 2.17
1349, 3439, 3479, 3665, 5044, 5246, 5298, 5400, 6530, 6778, 6808, 9685,
9914, 10014, 10038, 10631, 10873, 11438, 11607, 11638, 11741, 12140,
13412, 13542, 13601, 13603, 13604, 13629, 13679, 13696, 13698, 13717,
13741, 13939, 13950, 13952, 13966, 14042, 14047, 14090, 14150, 14151,
14152, 14154, 14157, 14166, 14173, 14195, 14237, 14251, 14252, 14283,
14298, 14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14368,
14376, 14417, 14459, 14476, 14477, 14501, 14505, 14510, 14516, 14518,
14519, 14530, 14532, 14538, 14543, 14544, 14545, 14557, 14562, 14568,
14576, 14579, 14583, 14587, 14595, 14602, 14610, 14621, 14638, 14645,
14648, 14652, 14660, 14661, 14669, 14672, 14683, 14694, 14716, 14743,
14767, 14783, 14784, 14785, 14793, 14796, 14797, 14801, 14805, 14807,
14809, 14811, 14815, 14821, 14824, 14828, 14831, 14838.
13741, 13763, 13939, 13950, 13952, 13966, 14042, 14047, 14090, 14150,
14151, 14152, 14154, 14157, 14166, 14173, 14195, 14237, 14251, 14252,
14283, 14298, 14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349,
14368, 14376, 14417, 14459, 14476, 14477, 14501, 14505, 14510, 14516,
14518, 14519, 14530, 14532, 14538, 14543, 14544, 14545, 14557, 14562,
14568, 14576, 14579, 14583, 14587, 14595, 14602, 14610, 14621, 14638,
14645, 14648, 14652, 14660, 14661, 14669, 14672, 14683, 14694, 14716,
14743, 14767, 14783, 14784, 14785, 14793, 14796, 14797, 14801, 14805,
14807, 14809, 14811, 14815, 14821, 14824, 14828, 14831, 14838.
* Port to ARM AArch64 contributed by Linaro.

11
sunrpc/bindrsvprt.c

@ -35,6 +35,12 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <bits/libc-lock.h>
/*
* Locks the static variables in this file.
*/
__libc_lock_define_initialized (static, lock);
/*
* Bind a socket to a privileged IP port
@ -74,6 +80,9 @@ bindresvport (int sd, struct sockaddr_in *sin)
int nports = ENDPORT - startport + 1;
int endport = ENDPORT;
__libc_lock_lock (lock);
again:
for (i = 0; i < nports; ++i)
{
@ -94,6 +103,8 @@ bindresvport (int sd, struct sockaddr_in *sin)
goto again;
}
__libc_lock_unlock (lock);
return res;
}
libc_hidden_def (bindresvport)

Loading…
Cancel
Save