bin/60287: [patch] NSS does not handle NSS_STATUS_TRYAGAIN properly

Lachlan O'Dea odela01 at ca.com
Thu Dec 18 19:14:17 PST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 19 Dec 2003, at 01:54, Jacques A. Vidrine wrote:

> Hi Lachlan,
>
> Thank you for your report!  I believe your analysis is correct.
>
> There is one subtlety that must also be resolved.  Within FreeBSD's
> nsswitch, one indicates that the given buffer is too small by setting
> errno to ERANGE and return RETURN.  The convention for GNU libc
> modules seems to be to set errno to ERANGE and return TRYAGAIN.
> Unfortunately, nss_ldap seems to do neither :-)  It does return
> TRYAGAIN, but it does not set errno, so one cannot distinguish between
> providing a too-small-buffer and, say, not enough heap memory.
>
> So, I believe I need to apply something approximating your patch,
> but also nss_ldap needs to be corrected to set ERANGE where
> appropriate.

Are you certain that the module should actually set errno? At the 
moment, nss_ldap does return ERANGE, but not in errno. In the LDAP 
case, getgrent seems to end up calling:

NSS_STATUS
_nss_ldap_getgrent_r (struct group *result,
                       char *buffer, size_t buflen, int *errnop)

In the buffer too small case, *errnop _is_ set to ERANGE. This ends up 
being checked by libc before it expands the buffer in getgr in 
getgrent.c.

In any case, I don't think my patch needs to be changed? I think you're 
saying that the errno code tells us why TRYAGAIN was returned. But 
regardless of why, TRYAGAIN implies that the operation can be, well, 
tried again. So we never want to set the terminate flag in the TRYAGAIN 
case, regardless of the errno value.

> P.S. If I cannot address this today, I'm afraid it will be early
> January before I get to it--- I'm leaving home early tomorrow and
> won't be back until then.

Okally-dokally. Thanks!

- --
Lachlan O'Dea
Computer Associates
Programmer
tel: +61 3 8416 5627
fax: +61 3 8416 5810
mobile: +61 412 390 650
odela01 at ca.com

Relax and enjoy your shoes!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQE/4m0ZoBZahcUBONoRAv8JAJwOKOWRWJ6xh5IVlrhx07EknzPfhgCgjiCf
f93pzISGJHeDQC5tzIIRu0s=
=OElB
-----END PGP SIGNATURE-----



More information about the freebsd-bugs mailing list