[GRASS-SVN] r38870 - grass/trunk/general/g.parser

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 26 06:34:31 EDT 2009


Author: glynn
Date: 2009-08-26 06:34:30 -0400 (Wed, 26 Aug 2009)
New Revision: 38870

Modified:
   grass/trunk/general/g.parser/main.c
Log:
Use G_asprintf() to avoid buffer overrun


Modified: grass/trunk/general/g.parser/main.c
===================================================================
--- grass/trunk/general/g.parser/main.c	2009-08-26 08:56:38 UTC (rev 38869)
+++ grass/trunk/general/g.parser/main.c	2009-08-26 10:34:30 UTC (rev 38870)
@@ -307,19 +307,20 @@
     }
 
     for (option = ctx->first_option; option; option = option->next_opt) {
-	char buff[4096], upper[4096];
+	char upper[4096];
+	char *str;
 
-	sprintf(buff, "GIS_OPT_%s=%s", option->key,
-		option->answer ? option->answer : "");
-	putenv(G_store(buff));
+	G_asprintf(&str, "GIS_OPT_%s=%s", option->key,
+		   option->answer ? option->answer : "");
+	putenv(str);
 
 	strcpy(upper, option->key);
 	G_str_to_upper(upper);
-	sprintf(buff, "GIS_OPT_%s=%s", upper,
-		option->answer ? option->answer : "");
+	G_asprintf(&str, "GIS_OPT_%s=%s", upper,
+		   option->answer ? option->answer : "");
 
-	G_debug(2, "set %s", buff);
-	putenv(G_store(buff));
+	G_debug(2, "set %s", str);
+	putenv(str);
     }
 
 #ifdef __MINGW32__



More information about the grass-commit mailing list