[GRASS-dev] d.legend uses a static buffer for `map='
Martin Landa
landa.martin at gmail.com
Mon Jan 7 04:48:18 EST 2008
Hi,
applied in trunk, thanks. Regards, Martin
http://trac.osgeo.org/grass/changeset/29587
2008/1/7, Ivan Shmakov <ivan at theory.asu.ru>:
> As of a recent SVN HEAD, `d.legend' uses a static buffer to
> store the value of the `map' option. It's therefore impossible
> to pass raster names more than 63 bytes long to `d.legend'.
> Since I don't see why a static buffer may be necessary here, I
> suggest the following (yet untested) patch.
>
> diff --git a/display/d.legend/main.c b/display/d.legend/main.c
> index d827d04..324012d 100644
> --- a/display/d.legend/main.c
> +++ b/display/d.legend/main.c
> @@ -39,7 +39,7 @@ int main( int argc, char **argv )
> {
> char *mapset ;
> char buff[512];
> - char map_name[64] ;
> + const char *map_name;
> char window_name[64] ;
> int black ;
> int cats_num ;
> @@ -188,7 +188,7 @@ int main( int argc, char **argv )
> if (G_parser(argc, argv))
> exit(EXIT_FAILURE);
>
> - strcpy(map_name, opt1->answer) ;
> + map_name = opt1->answer;
>
> hide_catstr = hidestr->answer; /* note hide_catstr gets changed and re-read below */
> hide_catnum = hidenum->answer;
>
> PS. I've seen a number of other uses of static buffers scattered across
> the code, leading to both potential limits and crashes, which
> I'm on the way to investigate.
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
--
Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *
More information about the grass-dev
mailing list