On 05/16/2011 03:03 PM, Eric Blake wrote:
> getpwnam() returns ERANGE if the allocated buffer is too small.
So
> we should do something along the lines of
>
> size_t len = sysconf(_SC_GETPW_R_SIZE_MAX)
Guarded by #ifdef, and defaulting to -1 if _SC_GETPW_R_SIZE_MAX is not
defined (since it is a handy extension, but not present everywhere).
Or not - we only use it inside #if HAVE_FUNC_GETPWNAM_R and friends; so
far, all platforms that have the *_r functions also happen to have a
decent set of sysconf() names where we aren't running into compilation
errors by trying to use _SC_GETPW_R_SIZE_MAX.
But indeed this is the correct response.
I've posted
https://www.redhat.com/archives/libvir-list/2011-May/msg01074.html
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org