[GRASS-SVN] r52898 - grass/trunk/raster/r.reclass

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 25 06:25:49 PDT 2012


Author: mmetz
Date: 2012-08-25 06:25:48 -0700 (Sat, 25 Aug 2012)
New Revision: 52898

Modified:
   grass/trunk/raster/r.reclass/reclass.c
Log:
hamish: don't segfault on long map names (#800)

Modified: grass/trunk/raster/r.reclass/reclass.c
===================================================================
--- grass/trunk/raster/r.reclass/reclass.c	2012-08-25 13:19:07 UTC (rev 52897)
+++ grass/trunk/raster/r.reclass/reclass.c	2012-08-25 13:25:48 UTC (rev 52898)
@@ -208,7 +208,7 @@
     struct History hist;
     int is_reclass;
     FILE *fd;
-    char buf[256];
+    char buf[GNAME_MAX + GMAPSET_MAX];
 
     is_reclass = Rast_get_reclass(old_name, old_mapset, &old);
     if (is_reclass < 0)
@@ -230,7 +230,7 @@
 	G_fatal_error(_("Cannot create reclass file of <%s>"), new_name);
 
     if (!title) {
-	sprintf(buf, "Reclass of %s in %s", new.name, new.mapset);
+	G_snprintf(buf, sizeof(buf), "Reclass of %s in %s", new.name, new.mapset);
 	title = buf;
     }
 



More information about the grass-commit mailing list