On 19 February 2013 17:31, Andrey Simonenko <si...@comsys.ntu-kpi.kiev.ua>wrote:
It can require bigger buffer, since root can get the pw_password field > in the struct passwd{}. > > Since sysconf(_SC_GETPW_R_SIZE_MAX) does not work on FreeBSD, the buffer > for getpwnam_r() call should have at least (2 * MAXLOGNAME + 2 * > MAXPATHLEN + > _PASSWORD_LEN + 1) bytes (it is unclear how much is required for pw_gecos). > > This buffer can be dynamically reallocated until getpwnam_r() is not > return ERANGE error (the following code has not been compiled and > verified): > Is this really a better solution than to aim high right away? A series of malloc() calls should certainly have much higher overhead than the previous stack-allocated solution. A better compromise would be to do the lookup in a separate function, that allocates the buffer using alloca() instead, yes? Regards, Elias _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"