[GRASS-SVN] r52899 - grass/branches/releasebranch_6_4/raster/r.reclass

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


Author: mmetz
Date: 2012-08-25 06:26:31 -0700 (Sat, 25 Aug 2012)
New Revision: 52899

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

Modified: grass/branches/releasebranch_6_4/raster/r.reclass/reclass.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.reclass/reclass.c	2012-08-25 13:25:48 UTC (rev 52898)
+++ grass/branches/releasebranch_6_4/raster/r.reclass/reclass.c	2012-08-25 13:26:31 UTC (rev 52899)
@@ -229,7 +229,7 @@
 	G_fatal_error(_("Cannot create reclass file of <%s>"), new_name);
 
     if (title == NULL)
-	sprintf(title = buf, "Reclass of %s in %s", new.name, new.mapset);
+	G_snprintf(title = buf, sizeof(buf), "Reclass of %s in %s", new.name, new.mapset);
 
     if ((fd = G_fopen_new("cell", new_name)) == NULL)
 	G_fatal_error(_("Cannot create raster map <%s>"), new_name);
@@ -245,7 +245,9 @@
 
     G_short_history(new_name, "reclass", &hist);
     strcpy(hist.datsrc_1, "Reclassified map based on:");
-    sprintf(hist.datsrc_2, "  Map [%s] in mapset [%s]", new.name, new.mapset);
+    G_snprintf(hist.datsrc_2, RECORD_LEN, "  Map [%s] in mapset [%s]", new.name, new.mapset);
+
+    G_command_history(&hist);
     G_write_history(new_name, &hist);
 
     new_range(new_name, &new);



More information about the grass-commit mailing list