[MPlayer-dev-eng] [PATCH] fix for unconditional use of PATH_MAX

Fabian Franz FabianFranz at gmx.de
Wed Apr 30 19:39:27 CEST 2003


Am Mittwoch, 30. April 2003 00:29 schrieb Robert Millan:
> On Tue, Apr 29, 2003 at 11:25:09PM +0200, Fabien Tassin wrote:
> > this is defined in POSIX.1.
> > I just reread POSIX.4 and it says that pathconf()/fpathconf() must be
> > used to collect the information (here, using _PC_PATH_MAX).
> > If it returns -1 but does not set errno, then there is no limit
> > for the symbol. Else, PATH_MAX value is returned.
> > I agree that the default value should not be used directly but queried
> > instead.
>
> sure, if you want to be portable for systems that don't have PATH_MAX
> but do have specific limits depending on the path you specify
> (i never heard any of these, though).
>
> but keep in mind to have a fallback for dynamic allocation. the
> system might not define PATH_MAX and never return a value with pathconf
> other than -1 (this is the case for GNU).
>
> a realy portable code would look like this:
>
> #ifdef PATH_MAX
>   path_max = PATH_MAX;
> #else
>   path_max = pathconf("foo", _PC_PATHMAX);
> #endif
>   if (path_max == -1)
>      use dynamic allocation;
>   else
>      use static allocation;
>
> of course, if you don't care you can just use dynamic allocation for
> all. then it'd work ok everyplace but wouldn't be as much optimised.

I think we should stick to what we have now and just add, what I mentioned adn 
no it is no security risk, see Tobias Mail, about it.

cu

Fabian



More information about the MPlayer-dev-eng mailing list