[GRASS-SVN] r52906 - grass/branches/releasebranch_6_4/raster/simwe/simlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 25 07:00:52 PDT 2012


Author: mmetz
Date: 2012-08-25 07:00:52 -0700 (Sat, 25 Aug 2012)
New Revision: 52906

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

Modified: grass/branches/releasebranch_6_4/raster/simwe/simlib/output.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/simwe/simlib/output.c	2012-08-25 13:55:39 UTC (rev 52905)
+++ grass/branches/releasebranch_6_4/raster/simwe/simlib/output.c	2012-08-25 14:00:52 UTC (rev 52906)
@@ -28,7 +28,7 @@
     char *erdep0 = NULL;
     char *mapst = NULL;
     char *type;
-    char buf[256];
+    char buf[GNAME_MAX + 10];
     int ndigit;
     FCELL dat1, dat2;
     float a1, a2;
@@ -455,8 +455,10 @@
 
 	    type = "raster";
 	    G_short_history(erdep0, type, &hist1);
-	    sprintf(hist1.edhist[0], "The sediment flux file is %s", flux0);
+	    G_snprintf(hist1.edhist[0], RECORD_LEN,
+		       "The sediment flux file is %s", flux0);
 	    hist1.edlinecnt = 1;
+	    G_command_history(&hist1);
 	    G_write_history(erdep0, &hist1);
 	}
 	else {
@@ -471,8 +473,10 @@
 
 	    type = "raster";
 	    G_short_history(erdep, type, &hist1);
-	    sprintf(hist1.edhist[0], "The sediment flux file is %s", flux);
+	    G_snprintf(hist1.edhist[0], RECORD_LEN,
+		       "The sediment flux file is %s", flux);
 	    hist1.edlinecnt = 1;
+	    G_command_history(&hist1);
 	    G_write_history(erdep, &hist1);
 	}
     }
@@ -507,8 +511,10 @@
 	sprintf(hist.edhist[3], "mean source (si)=%e, mean infil=%e", si0,
 		infmean);
 
-	sprintf(hist.datsrc_1, "input files: %s %s %s", elevin, dxin, dyin);
-	sprintf(hist.datsrc_2, "input files: %s %s %s", rain, infil, manin);
+	G_snprintf(hist.datsrc_1, RECORD_LEN,
+		   "input files: %s %s %s", elevin, dxin, dyin);
+	G_snprintf(hist.datsrc_2, RECORD_LEN,
+		   "input files: %s %s %s", rain, infil, manin);
 	hist.edlinecnt = 4;
 
 	G_command_history(&hist);
@@ -611,7 +617,7 @@
     struct Colors colors;
     const char *mapst = NULL;
 
-    /*   char buf[256]; */
+    /*   char buf[GNAME_MAX + 10]; */
     FCELL dat1, dat2;
 
     /*   float a1,a2; */



More information about the grass-commit mailing list