[MPlayer-dev-eng] [patch 2/5] Dont hardcode filename length

Erik Auerswald auerswal at unix-ag.uni-kl.de
Wed Jan 5 11:55:50 CET 2011


Hi,

On Wed, Jan 05, 2011 at 11:43:51AM +0100, Erik Auerswald wrote:
> On Tue, Jan 04, 2011 at 09:35:03PM +0100, Tobias Diedrich wrote:
> > Use limits.h to get the maximum length instead of hardcoding it.
> > 
> > -     fname=malloc( 255 );
> > -     while ( fgets( fname,255,lst_f ) )
> > +     fname=malloc(PATH_MAX);
> > +     while ( fgets( fname,PATH_MAX,lst_f ) )
> 
> FWIW there is no guarantee that PATH_MAX even exists. See e.g.
> http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html or
> http://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html or
> http://bytes.com/topic/c/answers/215365-path_max
> 
> I'd thus suggest a configure check for PATH_MAX and providing some
> arbitrary fallback value, e.g. 255 as used currently(?).

The header to find PATH_MAX can differ:

Mac/FreeBSD
    /usr/include/sys/syslimits.h
Linux (Debian/Fedora Core)
    /usr/include/linux/limits.h
Solaris
    /usr/include/limits.h 
(from http://andre.stechert.org/urwhatu/2005/10/path_max.html)

Erik
-- 
If you use a kernel.org-based kernel, and you aren't updating to the
latest -stable updates, well, why are you using a kernel.org kernel in
the first place?
                        -- Greg Kroah-Hartman


More information about the MPlayer-dev-eng mailing list