Bug#656869: perl: MAXPATHLEN set too small

Samuel Thibault sthibault at debian.org
Sun Jan 29 22:38:35 UTC 2012


Hello,

Svante Signell, le Sun 22 Jan 2012 15:59:14 +0100, a écrit :
> In perl-5.14.2/ext/File-Glob/bsd_glob.c the following definitions are
> made:
> #ifndef MAXPATHLEN
> #  ifdef PATH_MAX
> #    define     MAXPATHLEN      PATH_MAX
> #  else
> #    define     MAXPATHLEN      1024
> #  endif
> #endif

Actually it's not even that line which gets to define MAXPATHLEN, but
perl.h:

#ifndef MAXPATHLEN
#  ifdef PATH_MAX
#    ifdef _POSIX_PATH_MAX
#       if PATH_MAX > _POSIX_PATH_MAX
/* POSIX 1990 (and pre) was ambiguous about whether PATH_MAX
 * included the null byte or not.  Later amendments of POSIX,
 * XPG4, the Austin Group, and the Single UNIX Specification
 * all explicitly include the null byte in the PATH_MAX.
 * Ditto for _POSIX_PATH_MAX. */
#         define MAXPATHLEN PATH_MAX
#       else
#         define MAXPATHLEN _POSIX_PATH_MAX
#       endif
#    else
#      define MAXPATHLEN (PATH_MAX+1)
#    endif
#  else
#    ifdef _POSIX_PATH_MAX
#       define MAXPATHLEN _POSIX_PATH_MAX
#    else
#       define MAXPATHLEN 1024>_/* Err on the large side. */
#    endif
#  endif
#endif

On GNU/Hurd, _POSIX_PATH_MAX is defined, as required by Posix, to the
minimal supported path size, 256. MAXPATHLEN ends up being already
defined to 256 even before bsd_glob.c hacks around it.

This behavior, while safe, is too conservative: If no maximum is
specified, there is none, and 256 is not very big by nowadays standard,
as bug 645552 shows :)

Samuel






More information about the Perl-maintainers mailing list