Re: Possible bug in NFSv4 with krb5p security?

From: Elias Mårtenson <lokedhs_at_gmail.com>
Date: Tue, 19 Feb 2013 17:35:50 +0800
On 19 February 2013 17:31, Andrey Simonenko <simon_at_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
Received on Tue Feb 19 2013 - 08:35:51 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:35 UTC