[GRASS-dev] d.legend uses a static buffer for `map='

Markus Neteler neteler at osgeo.org
Thu Jan 10 03:18:04 EST 2008


On Jan 8, 2008 8:18 PM, Glynn Clements <glynn at gclements.plus.com> wrote:
> Ivan Shmakov wrote:
> That isn't a problem; it's reasonably safe to assume that the names
> which appear in the list don't exceed that value (e.g. most
> filesystems won't let you have a name longer than that).
>
> >  >> $ nl -ba display/d.colors/main.c
> >  >> ...
> >  >>     25    int
> >  >>     26    main (int argc, char **argv)
> >  >>     27    {
> >  >>     28        char name[128] = "";
> >
> >  > Right. We encourage developers to replace these with the defined
> >  > constants as they encounter them.
> >
> >       ACK.
>
> Well, it's not as if anyone is going to sytematically examine the
> entire GRASS source code to find such cases.
>
> > PS.  Shouldn't G__open () use GPATH_MAX as well?
>
> Yes. And GNAME_MAX and GMAPSET_MAX.
>
> And it shouldn't be freeing the mapset either.
>

Here are a couple of candidates:

cd lib/gis/
grep path *.c | grep char | grep -v GPATH_MAX | grep '\['
closecell.c:    char path[4096];
get_ellipse.c:    char ipath[1024], *str, *str1;
get_projinfo.c: char path[1024];
get_projinfo.c: char path[1024];
get_projname.c: char path[1024], buff[1024], answer[50], *a;
get_window.c:char path[1024];
make_loc.c:    char     path[2048];
make_mapset.c:    char  path[2048];
myname.c:    char path[500];
open.c:    char path[1024];
remove.c:       char path2[4096];

Change all of them to GPATH_MAX?

Markus


More information about the grass-dev mailing list