[GRASS-dev] etc file finder, take 2

Hamish hamish_nospam at yahoo.com
Fri Apr 20 03:09:12 EDT 2007


> Hamish wrote:
> > > use GPATH_MAX as the size of the path buffer (I've
> > > been replacing various random constants with that value as I find
> > > them; also for GNAME_MAX and GMAPSET_MAX)..
> > 
> > more of a comment than a question-
> > 
> > "char input_map[GNAME_MAX];" is often used to hold input=map at mapset
> > name, when the array often should be able to hold "GNAME_MAX + @ +
> > GMAPSET_MAX + \0" = 514 chars.
> > 
> > GNAME_MAX is long enough (256, gis.h) that map at mapset should rarely
> > exceed that, but it's something to look out for.
> > 
> > Perhaps gis.h should also have G_FULLYQUALIFIED_MAX ?

Glynn:
> Who said that GNAME_MAX referred to the length of an *unqualified*
> name?
> 
> It's just an arbitrary value used for array dimensions; nothing
> actually checks map names against that value.


/* File/directory name lengths */
#define GNAME_MAX 256
#define GMAPSET_MAX 256

#define GPATH_MAX 4096


if GMAPSET_MAX is 256, and GNAME_MAX should be able to hold name at mapset,
shouldn't GNAME_MAX be at least GMAPSET_MAX+2? 
[2= 1 char long mapset name + @]

otherwise concat can theoretically overflow.

(playing devil's advocate here to make the allocs a little more bad-
assumption-proof)


Hamish




More information about the grass-dev mailing list