misc/95239: nftw() returns EINVAL for large values of maxfds when it should not

Bruce Evans bde at zeta.org.au
Tue Apr 4 06:07:12 UTC 2006


On Sun, 2 Apr 2006, Todd Miller wrote:

>> Description:
> The nftw(3) I wrote for OpenBSD that is now used by FreeBSD has a bug where it returns -1 and sets errno to EINVAL when maxfds > OPEN_MAX.  However, only the older ftw(3) should have this restriction (see single unix or POSIX).
>
> I've inluded the fix I used in OpenBSD but due to the web form submission the patch will likely have to be applied by hand (it is small).

It is a bug for anything to have a limit of OPEN_MAX for anything.
The POSIX limit for everything that has a limit on open files, including
ftw, is {OPEN_MAX} is quite different.  It is a bug for BSD systems
to define OPEN_MAX, since defining OPEN_MAX says that the limit on
open files is a compile-time constant but it is actually a runtime
constant and highly variable.  On FreeBSD at least, {OPEN_MAX} =
sysconf(_SC_OPEN_MAX) is the associated rlimit.

Bruce


More information about the freebsd-bugs mailing list