[GRASS-SVN] r50180 - grass/branches/develbranch_6/display/d.profile

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 14 19:04:29 EST 2012


Author: hamish
Date: 2012-01-14 16:04:29 -0800 (Sat, 14 Jan 2012)
New Revision: 50180

Modified:
   grass/branches/develbranch_6/display/d.profile/Range.c
Log:
avoid out-of-bounds buffer access (#1312)

Modified: grass/branches/develbranch_6/display/d.profile/Range.c
===================================================================
--- grass/branches/develbranch_6/display/d.profile/Range.c	2012-01-14 22:16:14 UTC (rev 50179)
+++ grass/branches/develbranch_6/display/d.profile/Range.c	2012-01-15 00:04:29 UTC (rev 50180)
@@ -7,7 +7,7 @@
 {
     char inbuf[512];		/* input buffer for reading stats */
     int done = 0;
-    char stats_cmd[512];	/* string for r.stats command */
+    char stats_cmd[GPATH_MAX];	/* string for r.stats command */
     char *temp_fname;		/* temp file name */
     FILE *temp_file;		/* temp file pointer */
     long int cat;		/* a category value */
@@ -24,7 +24,7 @@
 
     first = 1;
     while (!done) {
-	if (fgets(inbuf, 1024, temp_file) != NULL) {
+	if (fgets(inbuf, sizeof(inbuf), temp_file) != NULL) {
 	    if (sscanf(inbuf, "%ld %ld", &cat, &stat) == 2) {
 		if (first) {
 		    *max = cat;



More information about the grass-commit mailing list