[PATCH]:bindresvport should check /etc/services

Thorsten Kukuk kukuk@suse.de
Sun Dec 1 04:04:00 GMT 2002


On Tue, Nov 26, Rajasekhar Inguva wrote:

> Hi All,
> 
> The glibc routine bindresvport(), in it's current implementation, randomly
> tries to a bind to a port number in the range 600-1023. It does not check
> if the selected port number has an entry in /etc/services. Due to this a
> server using bindresvport() might grab a port which belongs to a well
> known
> service as described in /etc/services. And should the well known service
> start later it would fail to bind to it's port.
> 
> The patch below would take care of this situation by making bindresvport()
> ignore all ports which have an entry in /etc/services. This is achieved by
> calling getservbyport() which returns NULL if a specified port number does
> not have an entry in /etc/services.

With this patch applied, no port will be found, if somebody uses 
the /etc/services file from IANA. All ports below 1023 are official
registered. There is no port reserved for RPC, so you have to find
another solution.

  Thorsten

-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/        kukuk@suse.de
SuSE Linux AG        Deutschherrnstr. 15-19        D-90429 Nuernberg
--------------------------------------------------------------------    
Key fingerprint = A368 676B 5E1B 3E46 CFCE  2D97 F8FD 4E23 56C6 FB4B



More information about the Libc-alpha mailing list