Janneke Nieuwenhuizen <jann...@gnu.org> writes:

> Sam Hartman writes:
>
>> TL;DR: Is it time for the rest of Debian to stop conforming to HURD's
>> lack of maximums for path and hostname?
>
> The GNU Coding standards say: Avoid arbitrary limits
> (<https://www.gnu.org/prep/standards/html_node/Semantics.html>.

I agree, but it is going further than that: POSIX doesn't require
PATH_MAX and I believe the semantics of PATH_MAX is not what some code
assume that the symbol has.  See below for specified semantics.

I believe use of PATH_MAX as a char[] array length specifier is usually
an indicator of a bug or a security vulenrability waiting to happen.  It
is not a idiom we should strive towards.

/Simon

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html

Pathname Variable Values

The values in the following list may be constants within an
implementation or may vary from one pathname to another. For example,
file systems or directories may have different characteristics.

A definition of one of the symbolic constants in the following list
shall be omitted from the <limits.h> header on specific implementations
where the corresponding value is equal to or greater than the stated
minimum, but where the value can vary depending on the file to which it
is applied. The actual value supported for a specific pathname shall be
provided by the pathconf() function.

{PATH_MAX}

    Maximum number of bytes the implementation stores as a pathname in a
    user-supplied buffer of unspecified size, including the terminating
    null character. Minimum number the implementation shall accept as
    the maximum number of bytes in a pathname.

    Minimum Acceptable Value: {_POSIX_PATH_MAX}

{_POSIX_PATH_MAX}
    Minimum number the implementation shall accept as the maximum number of 
bytes in a pathname.
    Value: 256

{_XOPEN_PATH_MAX}
    [XSI] [Option Start]
    Minimum number the implementation shall accept as the maximum number of 
bytes in a pathname.
    Value: 1024 [Option End]

Attachment: signature.asc
Description: PGP signature

Reply via email to