Calling properly getpwuid_r

Thomas Segismont tsegismo@redhat.com
Tue Feb 12 15:53:00 GMT 2013


Le 12/02/2013 16:47, Siddhesh Poyarekar a écrit :
> On 12 February 2013 21:11, Thomas Segismont <tsegismo@redhat.com> wrote:
>> On the libc manual, there is an example on how to call gethostbyname_r:
>> http://www.gnu.org/software/libc/manual/html_node/Host-Names.html
>>
>> As getpwuid_r seems to be backed by the same code in getXXbyYY_r.c, is it
>> also recommended to call it in a while loop to deal with erange errors?
>
> Yes.
>
>> Is there a particular reason for this?
>
> The string fields in the struct paswd returned are stored in the
> caller-supplied buffer.  The call will return ERANGE if the buffer is
> not large enough.
>
>

Thanks for this rather quick answer!



More information about the Libc-help mailing list