[GRASS-SVN] r52903 - in grass/branches/releasebranch_6_4/raster/r.support: modcolr modhist
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 25 06:47:04 PDT 2012
Author: mmetz
Date: 2012-08-25 06:47:03 -0700 (Sat, 25 Aug 2012)
New Revision: 52903
Modified:
grass/branches/releasebranch_6_4/raster/r.support/modcolr/modcolr.c
grass/branches/releasebranch_6_4/raster/r.support/modhist/modhist.c
Log:
hamish: strncpy doesn't always null-terminate (#1315)
Modified: grass/branches/releasebranch_6_4/raster/r.support/modcolr/modcolr.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.support/modcolr/modcolr.c 2012-08-25 13:43:06 UTC (rev 52902)
+++ grass/branches/releasebranch_6_4/raster/r.support/modcolr/modcolr.c 2012-08-25 13:47:03 UTC (rev 52903)
@@ -25,7 +25,7 @@
int main(int argc, char *argv[])
{
int stat;
- char name[64];
+ char name[GNAME_MAX];
char *mapset;
struct Colors pcolr;
@@ -41,6 +41,7 @@
}
else {
strncpy(name, argv[1], sizeof(name));
+ name[sizeof(name) - 1] = '\0';
if ((mapset = G_find_cell2(name, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
}
Modified: grass/branches/releasebranch_6_4/raster/r.support/modhist/modhist.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.support/modhist/modhist.c 2012-08-25 13:43:06 UTC (rev 52902)
+++ grass/branches/releasebranch_6_4/raster/r.support/modhist/modhist.c 2012-08-25 13:47:03 UTC (rev 52903)
@@ -25,7 +25,7 @@
int main(int argc, char *argv[])
{
- char name[64];
+ char name[GNAME_MAX];
char *mapset;
struct History hist;
@@ -42,6 +42,7 @@
}
else {
strncpy(name, argv[1], sizeof(name));
+ name[sizeof(name) - 1] = '\0';
if ((mapset = G_find_cell2(name, G_mapset())) == NULL)
G_fatal_error(_("Raster file [%s] not found. Exiting."), argv[1]);
}
More information about the grass-commit
mailing list