tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

MAXPATHLEN vs PATH_MAX



In src/sys/sys/param.h, MAXPATHLEN is defined as PATH_MAX.

In POSIX, PATH_MAX is defined like this:

{PATH_MAX}
    Maximum number of bytes the implementation will store as a pathname
in a user-supplied buffer of unspecified size, including the terminating
null character. Minimum number the implementation will accept as the
maximum number of bytes in a pathname.

So the maximum length of a path is PATH_MAX - 1.

How is MAXPATHLEN to be interpreted: the maximum length of the string
as the name seems to imply, or the maximum number of bytes, including
terminating nul, occupied by the maximum path?

In the sources, we have the two uses:

in src/bin/pax/ar_subs.c, the buffer allocated for a call to realpath(3)
is MAXPATHLEN (no problem, since realpath will not store more than
MAX_PATH).

In src/crypto/dist/ipsec-tools/src/racoon/privsep.c, we have a buffer of
MAXPATHLEN + 1, taking into account a trailing nul and interpreting
'LEN' as in strlen(3), which seems logical.

Shouldn't be MAXPATHLEN be defined as PATH_MAX - 1?
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index