Subject: Re: getpwent(3) funcs return static structure
To: Johan Danielsson <joda@pdc.kth.se>
From: David Brownlee <david@mono.org>
List: current-users
Date: 03/03/1997 12:09:04
On 2 Mar 1997, Johan Danielsson wrote:

> Rick Byers <rickb@iaw.on.ca> writes:
> 
> > Shouldn't it atleast be mentioned in the man pages?
> 
> getpwent(3):
> 
> BUGS
>      The functions getpwent(), getpwnam(), and getpwuid(), leave their results
>      in an internal static object and return a pointer to that object. Subse-
>      quent calls to the same function will modify the same object.
> 
> The right thing to do is to use the thread-safe getpw*_r(), that
> unfortunately aren't available in NetBSD.
> 
	The above description does not make it clear that a call to
	getpwuid(getuid()) would overwrite the buffer user earlier by
	getpwent(). This could be misleading. 
	(Being in an anal mood this morning I've just sent a PR on this :)

		David/abs	david@{mono.org,southern.com,mhm-internet.com}

     Microsoft: Asks you where you want to go. NetBSD gets you there.
System Manager: Southern Studios Ltd, PO Box 59, London N22 1AR.
  System Admin: MHM Internet, 14 Barley Mow Passage, Chiswick, London W4 4PH.
         SysOP: Monochrome, Largest UK Internet BBS - 'telnet mono.org'.