[GRASS-SVN] r60401 - in grass/branches/releasebranch_6_4: doc/raster/r.example general/g.region imagery/i.cca imagery/i.fft imagery/i.ifft imagery/i.zc raster/r.average raster/r.bitpattern raster/r.buffer raster/r.clump raster/r.cost raster/r.in.ascii raster/r.in.gdal raster/r.in.mat raster/r.los raster/r.median raster/r.mode raster/r.neighbors raster/r.random raster/r.random.cells raster/r.random.surface raster/r.reclass raster/r.recode raster/r.resample raster/r.rescale raster/r.rescale.eq raster/r.slope.aspect raster/r.surf.gauss raster/r.surf.idw raster/r.surf.idw2 raster/r.surf.random raster/r.texture raster/r.to.rast3 raster/r.to.rast3elev raster/r.walk raster/r.water.outlet raster/wildfire/r.ros raster/wildfire/r.spread raster/wildfire/r.spreadpath raster3d/r3.cross.rast raster3d/r3.mkdspf raster3d/r3.showdspf raster3d/r3.to.rast vector/v.edit vector/v.in.ogr vector/v.kernel vector/v.surf.idw vector/v.to.rast3
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 21 20:10:25 PDT 2014
Author: neteler
Date: 2014-05-21 20:10:25 -0700 (Wed, 21 May 2014)
New Revision: 60401
Modified:
grass/branches/releasebranch_6_4/doc/raster/r.example/main.c
grass/branches/releasebranch_6_4/general/g.region/main.c
grass/branches/releasebranch_6_4/imagery/i.cca/main.c
grass/branches/releasebranch_6_4/imagery/i.fft/fftmain.c
grass/branches/releasebranch_6_4/imagery/i.ifft/ifftmain.c
grass/branches/releasebranch_6_4/imagery/i.zc/main.c
grass/branches/releasebranch_6_4/raster/r.average/main.c
grass/branches/releasebranch_6_4/raster/r.bitpattern/main.c
grass/branches/releasebranch_6_4/raster/r.buffer/main.c
grass/branches/releasebranch_6_4/raster/r.clump/main.c
grass/branches/releasebranch_6_4/raster/r.cost/main.c
grass/branches/releasebranch_6_4/raster/r.in.ascii/main.c
grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c
grass/branches/releasebranch_6_4/raster/r.in.mat/main.c
grass/branches/releasebranch_6_4/raster/r.los/main.c
grass/branches/releasebranch_6_4/raster/r.median/main.c
grass/branches/releasebranch_6_4/raster/r.mode/main.c
grass/branches/releasebranch_6_4/raster/r.neighbors/main.c
grass/branches/releasebranch_6_4/raster/r.random.cells/init.c
grass/branches/releasebranch_6_4/raster/r.random.surface/init.c
grass/branches/releasebranch_6_4/raster/r.random/main.c
grass/branches/releasebranch_6_4/raster/r.reclass/main.c
grass/branches/releasebranch_6_4/raster/r.recode/main.c
grass/branches/releasebranch_6_4/raster/r.resample/main.c
grass/branches/releasebranch_6_4/raster/r.rescale.eq/main.c
grass/branches/releasebranch_6_4/raster/r.rescale/main.c
grass/branches/releasebranch_6_4/raster/r.slope.aspect/opennew.c
grass/branches/releasebranch_6_4/raster/r.surf.gauss/main.c
grass/branches/releasebranch_6_4/raster/r.surf.idw/main.c
grass/branches/releasebranch_6_4/raster/r.surf.idw2/main.c
grass/branches/releasebranch_6_4/raster/r.surf.random/main.c
grass/branches/releasebranch_6_4/raster/r.texture/main.c
grass/branches/releasebranch_6_4/raster/r.to.rast3/main.c
grass/branches/releasebranch_6_4/raster/r.to.rast3elev/main.c
grass/branches/releasebranch_6_4/raster/r.walk/main.c
grass/branches/releasebranch_6_4/raster/r.water.outlet/legal.c
grass/branches/releasebranch_6_4/raster/r.water.outlet/main.c
grass/branches/releasebranch_6_4/raster/wildfire/r.ros/main.c
grass/branches/releasebranch_6_4/raster/wildfire/r.spread/main.c
grass/branches/releasebranch_6_4/raster/wildfire/r.spreadpath/main.c
grass/branches/releasebranch_6_4/raster3d/r3.cross.rast/main.c
grass/branches/releasebranch_6_4/raster3d/r3.mkdspf/r3_find.c
grass/branches/releasebranch_6_4/raster3d/r3.showdspf/r3_find.c
grass/branches/releasebranch_6_4/raster3d/r3.to.rast/main.c
grass/branches/releasebranch_6_4/vector/v.edit/main.c
grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c
grass/branches/releasebranch_6_4/vector/v.kernel/main.c
grass/branches/releasebranch_6_4/vector/v.surf.idw/main.c
grass/branches/releasebranch_6_4/vector/v.to.rast3/main.c
Log:
reinstate G_legal_filename() calls removed in r60000 (backport of r32820)
Modified: grass/branches/releasebranch_6_4/doc/raster/r.example/main.c
===================================================================
--- grass/branches/releasebranch_6_4/doc/raster/r.example/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/doc/raster/r.example/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -110,6 +110,10 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
+ if (G_legal_filename(result) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), result);
+
+
/* determine the inputmap type (CELL/FCELL/DCELL) */
data_type = G_raster_map_type(name, mapset);
Modified: grass/branches/releasebranch_6_4/general/g.region/main.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.region/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/general/g.region/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -838,6 +838,8 @@
/* save= */
if ((name = parm.save->answer)) {
+ if (G_legal_filename(name) < 0)
+ G_fatal_error(_("<%s> is an illegal region name"), name);
G_copy(&temp_window, &window, sizeof(window));
adjust_window(&temp_window, 0, 0, 0);
if (G__put_window(&temp_window, "windows", name) < 0)
Modified: grass/branches/releasebranch_6_4/imagery/i.cca/main.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.cca/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/imagery/i.cca/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -104,6 +104,18 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (G_legal_filename(grp_opt->answer) < 0)
+ G_fatal_error(_("Illegal group name <%s>"), grp_opt->answer);
+
+ if (G_legal_filename(subgrp_opt->answer) < 0)
+ G_fatal_error(_("Illegal subgroup name <%s>"), subgrp_opt->answer);
+
+ if (G_legal_filename(sig_opt->answer) < 0)
+ G_fatal_error(_("Illegal signature file name <%s>"), sig_opt->answer);
+
+ if (G_legal_filename(out_opt->answer) < 0)
+ G_fatal_error(_("Illegal output file name <%s>"), out_opt->answer);
+
/* check group, subgroup */
I_init_group_ref(&refs);
if (I_find_group(grp_opt->answer) <= 0)
Modified: grass/branches/releasebranch_6_4/imagery/i.fft/fftmain.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.fft/fftmain.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/imagery/i.fft/fftmain.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -115,6 +115,15 @@
G_warning(_("Raster MASK found, consider to remove "
"(see man-page). Will continue..."));
+
+ /* check command line args for validity */
+ if (G_legal_filename(Cellmap_real) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), Cellmap_real);
+
+ if (G_legal_filename(Cellmap_imag) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"),
+ Cellmap_imag);
+
sscanf(op4->answer, "%d", &Range);
if (Range <= 0)
G_fatal_error(_("Range less than or equal to zero not allowed"));
Modified: grass/branches/releasebranch_6_4/imagery/i.ifft/ifftmain.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.ifft/ifftmain.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/imagery/i.ifft/ifftmain.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -111,6 +111,11 @@
G_fatal_error(_("Unable to open imaginary-image in the 'cell_misc' directory. "
"Raster map probably wasn't created by i.fft"));
+ /* check command line args for validity */
+ if (G_legal_filename(Cellmap_orig) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"),
+ Cellmap_orig);
+
/* get and compare the original window data */
get_orig_window(&orig_wind, realmapset, imagmapset);
Modified: grass/branches/releasebranch_6_4/imagery/i.zc/main.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.zc/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/imagery/i.zc/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -114,6 +114,10 @@
if (inputfd < 0)
exit(EXIT_FAILURE);
+ /* check command line args for validity */
+ if (G_legal_filename(OUTPUT_MAP) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), OUTPUT_MAP);
+
sscanf(threshold->answer, "%1lf", &Thresh);
if (Thresh <= 0.0)
G_fatal_error(_("Threshold less than or equal to zero not allowed"));
Modified: grass/branches/releasebranch_6_4/raster/r.average/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.average/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.average/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -74,6 +74,9 @@
if (!(mapset = G_find_cell(covermap->answer, "")))
G_fatal_error(_("Raster map <%s> not found"), covermap->answer);
+ if (G_legal_filename(outputmap->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), outputmap->answer);
+
if ((usecats = flag_c->answer)) {
if (G_read_cats(covermap->answer, mapset, &cats) < 0)
G_fatal_error(_("Error reading category file for <%s>"),
Modified: grass/branches/releasebranch_6_4/raster/r.bitpattern/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.bitpattern/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.bitpattern/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -100,6 +100,9 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
+ if (G_legal_filename(result) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), result);
+
/*if Gispf() error */
if ((infd = G_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
Modified: grass/branches/releasebranch_6_4/raster/r.buffer/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.buffer/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.buffer/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -126,6 +126,9 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), input);
+ if (G_legal_filename(output) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), output);
+
/* parse units */
if (opt4->answer == NULL)
units = "meters";
Modified: grass/branches/releasebranch_6_4/raster/r.clump/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.clump/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.clump/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -86,6 +86,9 @@
if (!mapset)
G_fatal_error(_("Raster map <%s> not found"), INPUT);
+ if (G_legal_filename(OUTPUT) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), OUTPUT);
+
in_fd = G_open_cell_old(name, mapset);
if (in_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), INPUT);
Modified: grass/branches/releasebranch_6_4/raster/r.cost/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.cost/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.cost/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -346,6 +346,16 @@
move_dir_mapset = G_find_cell2(move_dir_layer, search_mapset);
}
+ /* Check if specified output layer name is legal */
+
+ if (G_legal_filename(cum_cost_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), cum_cost_layer);
+
+ if (dir == 1) {
+ if (G_legal_filename(move_dir_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), move_dir_layer);
+ }
+
/* Find number of rows and columns in window */
nrows = G_window_rows();
Modified: grass/branches/releasebranch_6_4/raster/r.in.ascii/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.in.ascii/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.in.ascii/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -199,6 +199,8 @@
rast_ptr = G_allocate_raster_buf(data_type);
rast = rast_ptr;
+ if (G_legal_filename(output) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), output);
cf = G_open_raster_new(output, data_type);
if (cf < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
Modified: grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -221,6 +221,9 @@
if (!output)
G_fatal_error(_("Name for output raster map not specified"));
+ if (G_legal_filename(output) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), output);
+
if (!parm.outloc->answer) { /* Check if the map exists */
if (G_find_cell2(output, G_mapset())) {
if (overwrite)
Modified: grass/branches/releasebranch_6_4/raster/r.in.mat/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.in.mat/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.in.mat/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -384,6 +384,8 @@
}
G_strip(map_name); /* remove leading and trailing whitespace */
+ if (G_legal_filename(map_name) != 1)
+ G_fatal_error(_("<%s> is an illegal file name"), map_name);
/* set region info */
Modified: grass/branches/releasebranch_6_4/raster/r.los/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.los/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.los/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -168,6 +168,10 @@
G_fatal_error(_("Raster map <%s> not found"), patt_layer);
}
+ /* check if specified output layer name is legal */
+ if (G_legal_filename(out_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), out_layer);
+
/* read header info for elevation layer */
if (G_get_cellhd(elev_layer, old_mapset, &cellhd_elev) < 0)
G_fatal_error(_("[%s]: Cannot read map header"), elev_layer);
Modified: grass/branches/releasebranch_6_4/raster/r.median/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.median/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.median/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -73,7 +73,8 @@
cover_mapset = G_find_cell2(covermap, "");
if (cover_mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), covermap);
-
+ if (G_legal_filename(outmap) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), outmap);
if (strcmp(G_mapset(), base_mapset) == 0 && strcmp(basemap, outmap) == 0)
G_fatal_error(_("Base map and output map <%s> must be different"),
outmap);
Modified: grass/branches/releasebranch_6_4/raster/r.mode/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.mode/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.mode/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -90,7 +90,9 @@
if (cover_mapset == NULL) {
G_fatal_error(_("%s: cover raster map not found"), covermap);
}
-
+ if (G_legal_filename(outmap) < 0) {
+ G_fatal_error(_("<%s> is an illegal file name"), outmap);
+ }
if (strcmp(G_mapset(), base_mapset) == 0 && strcmp(basemap, outmap) == 0) {
G_fatal_error(_("%s: base map and output map must be different"),
outmap);
Modified: grass/branches/releasebranch_6_4/raster/r.neighbors/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.neighbors/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.neighbors/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -193,6 +193,9 @@
G_fatal_error(_("Raster map <%s> not found"), p);
}
p = ncb.newcell.name = parm.output->answer;
+ if (G_legal_filename(p) < 0) {
+ G_fatal_error(_("<%s> is an illegal file name"), p);
+ }
ncb.newcell.mapset = G_mapset();
if (parm.weight->answer && parm.gauss->answer)
G_fatal_error(_("weight= and gauss= are mutually exclusive"));
Modified: grass/branches/releasebranch_6_4/raster/r.random/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.random/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -142,6 +142,16 @@
G_fatal_error(_("Note: one (or both) of %s and %s must be specified"),
parm.raster->key, parm.sites->key);
+ if (myState.outraster)
+ if (G_legal_filename(myState.outraster) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"),
+ myState.outraster);
+
+ if (myState.outvector)
+ if (G_legal_filename(myState.outvector) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"),
+ myState.outvector);
+
/* look for n[%] */
percent = has_percent(parm.npoints->answer);
if (percent) {
Modified: grass/branches/releasebranch_6_4/raster/r.random.cells/init.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/init.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/init.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -11,6 +11,7 @@
/* function prototypes */
static int comp_array(const void *p1, const void *p2);
+static void IsLegal(char *Name);
void Init(int argc, char **argv)
{
@@ -87,6 +88,8 @@
}
CellCount = Rs * Cs;
}
+
+ IsLegal(Output->answer);
sscanf(Distance->answer, "%lf", &MaxDist);
if (MaxDist < 0.0)
@@ -145,3 +148,11 @@
return (1);
return (0);
}
+
+
+static void IsLegal(char *Name)
+{
+ if (G_legal_filename(Name) == -1)
+ G_fatal_error(_("<%s> is an illegal name"),
+ Name);
+}
Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/init.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/init.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/init.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -11,6 +11,10 @@
#include "ransurf.h"
#include "local_proto.h"
+/* function prototypes */
+static void IsLegal(char *Name);
+
+
void Init(int argc, char **argv)
{
struct Option *Output;
@@ -162,6 +166,7 @@
NumMaps = 0;
OutNames = (char **)G_malloc(sizeof(char *));
for (i = 0; (Name = Output->answers[i]); i++) {
+ IsLegal(Name);
for (j = i - 1; j >= 0; j--) {
if (strcmp(OutNames[j], Name) == 0)
G_fatal_error
@@ -412,3 +417,11 @@
AllMaxDist *= 2.0;
}
+
+
+static void IsLegal(char *Name)
+{
+ if (G_legal_filename(Name) == -1)
+ G_fatal_error(_("<%s> is an illegal name"),
+ Name);
+}
Modified: grass/branches/releasebranch_6_4/raster/r.reclass/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.reclass/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.reclass/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -78,6 +78,9 @@
if (old_mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), parm.input->answer);
+ if (G_legal_filename(parm.output->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), parm.output->answer);
+
if (strcmp(parm.input->answer, parm.output->answer) == 0 &&
strcmp(old_mapset, G_mapset()) == 0)
G_fatal_error(_("Input map can NOT be the same as output map"));
Modified: grass/branches/releasebranch_6_4/raster/r.recode/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.recode/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.recode/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -80,6 +80,9 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
+ if (G_legal_filename(result) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), result);
+
if (strcmp(name, result) == 0 && strcmp(mapset, G_mapset()) == 0)
G_fatal_error(_("Input map can NOT be the same as output map"));
Modified: grass/branches/releasebranch_6_4/raster/r.resample/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.resample/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.resample/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -96,6 +96,9 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
+ if (G_legal_filename(result) < 0)
+ G_fatal_error("<%s> is an illegal file name", result);
+
hist_ok = G_read_history(name, mapset, &hist) >= 0;
colr_ok = G_read_colors(name, mapset, &colr) > 0;
cats_ok = G_read_cats(name, mapset, &cats) >= 0;
Modified: grass/branches/releasebranch_6_4/raster/r.rescale/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.rescale/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.rescale/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -112,6 +112,10 @@
sprintf(buf, "%s - not found\n", old_name);
G_fatal_error(buf);
}
+ if (G_legal_filename(new_name) < 0) {
+ sprintf(buf, "%s - illegal map name\n", new_name);
+ G_fatal_error(buf);
+ }
if (parm.from->answer) {
sscanf(parm.from->answers[0], "%ld", &old_min);
Modified: grass/branches/releasebranch_6_4/raster/r.rescale.eq/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.rescale.eq/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.rescale.eq/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -117,6 +117,10 @@
sprintf(buf, "%s - not found\n", old_name);
G_fatal_error(buf);
}
+ if (G_legal_filename(new_name) < 0) {
+ sprintf(buf, "%s - illegal map name\n", new_name);
+ G_fatal_error(buf);
+ }
get_stats(old_name, mapset, &statf);
if (parm.from->answer) {
Modified: grass/branches/releasebranch_6_4/raster/r.slope.aspect/opennew.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.slope.aspect/opennew.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.slope.aspect/opennew.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -7,6 +7,9 @@
{
int fd;
+ if (G_legal_filename(name) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), name);
+
if (wr_type < 0) /* default fp type */
fd = G_open_fp_cell_new(name);
else
Modified: grass/branches/releasebranch_6_4/raster/r.surf.gauss/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.surf.gauss/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.surf.gauss/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -72,6 +72,10 @@
sscanf(mean->answer, "%lf", &gauss_mean);
sscanf(sigma->answer, "%lf", &gauss_sigma);
+ /****** CHECK THE CELL FILE (OUT) DOES NOT ALREADY EXIST******/
+ if (G_legal_filename(out->answer) == '\0')
+ G_fatal_error(_("<%s> is an illegal file name"), out->answer);
+
/****** CREATE THE RANDOM CELL FILE ******/
gaussurf(out->answer, gauss_mean, gauss_sigma);
Modified: grass/branches/releasebranch_6_4/raster/r.surf.idw/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.surf.idw/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.surf.idw/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -107,6 +107,10 @@
if (layer_mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), input);
+ /* check if specified output layer name is legal */
+ if (G_legal_filename(output) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), output);
+
/* find number of rows and columns in window */
nrows = G_window_rows();
ncols = G_window_cols();
Modified: grass/branches/releasebranch_6_4/raster/r.surf.idw2/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.surf.idw2/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.surf.idw2/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -79,6 +79,9 @@
if ((G_projection() == PROJECTION_LL))
G_fatal_error(_("Lat/long databases not supported by r.surf.idw2. Use r.surf.idw instead!"));
+ if (G_legal_filename(parm.output->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), parm.output->answer);
+
if (sscanf(parm.npoints->answer, "%d", &search_points) != 1 ||
search_points < 1)
G_fatal_error(_("%s=%s - illegal number of interpolation points"),
Modified: grass/branches/releasebranch_6_4/raster/r.surf.random/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.surf.random/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.surf.random/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -68,6 +68,10 @@
exit(EXIT_FAILURE); /* Returns a 0 if sucessful */
+ if (G_legal_filename(out->answer) != 1)
+ G_fatal_error("Illegal file name. Please try another.");
+
+
randsurf(out->answer, atoi(min->answer), atoi(max->answer),
i_flag->answer);
Modified: grass/branches/releasebranch_6_4/raster/r.texture/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.texture/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.texture/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -227,6 +227,9 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
+ if (G_legal_filename(result) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), result);
+
if ((infd = G_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
Modified: grass/branches/releasebranch_6_4/raster/r.to.rast3/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.to.rast3/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.to.rast3/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -235,6 +235,10 @@
if (fd == NULL)
fatal_error(map, NULL, 0, _("Out of memory"));
+ if (G_legal_filename(param.output->answer) < 0)
+ fatal_error(map, NULL, 0, _("Illegal output file name"));
+
+
mapset = NULL;
name = NULL;
Modified: grass/branches/releasebranch_6_4/raster/r.to.rast3elev/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.to.rast3elev/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.to.rast3elev/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -468,6 +468,10 @@
G_set_window(&window2d);
}
+ if (G_legal_filename(param.output->answer) < 0)
+ G3d_fatalError(_("<%s> is an illegal file name"),
+ param.output->answer);
+
G_debug(2, "Open 3d raster map %s", param.output->answer);
/*open G3D output map */
Modified: grass/branches/releasebranch_6_4/raster/r.walk/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.walk/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.walk/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -548,6 +548,16 @@
if (cost_mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), cost_layer);
+ /* Check if specified output layer name is legal */
+
+ if (G_legal_filename(cum_cost_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), cum_cost_layer);
+
+ if (dir == 1) {
+ if (G_legal_filename(move_dir_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), move_dir_layer);
+ }
+
/* Find number of rows and columns in window */
nrows = G_window_rows();
Modified: grass/branches/releasebranch_6_4/raster/r.water.outlet/legal.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.water.outlet/legal.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.water.outlet/legal.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -2,6 +2,18 @@
#include <grass/gis.h>
#include <grass/glocale.h>
+int do_legal(char *file_name)
+{
+ char *buf;
+
+ if (G_legal_filename(file_name) == -1) {
+ G_asprintf(&buf, _("<%s> is an illegal file name"), file_name);
+ G_fatal_error(buf);
+ }
+
+ return 0;
+}
+
char *do_exist(char *file_name)
{
char *buf, *file_mapset;
Modified: grass/branches/releasebranch_6_4/raster/r.water.outlet/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.water.outlet/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/r.water.outlet/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -109,7 +109,7 @@
dr_f = ba_f = N_f = E_f = errr = 0;
drain_mapset = do_exist(drain_name);
-
+ do_legal(basin_name);
nrows = G_window_rows();
ncols = G_window_cols();
total = nrows * ncols;
Modified: grass/branches/releasebranch_6_4/raster/wildfire/r.ros/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/wildfire/r.ros/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/wildfire/r.ros/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -410,6 +410,10 @@
}
}
+ /* Check if specified output layer name IS LEGAL */
+ if (G_legal_filename(parm.output->answer) < 0)
+ G_fatal_error("%s - illegal name", parm.output->answer);
+
/*assign names of the three output ROS layers */
sprintf(name_base, "%s.base", parm.output->answer);
sprintf(name_max, "%s.max", parm.output->answer);
Modified: grass/branches/releasebranch_6_4/raster/wildfire/r.spread/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/wildfire/r.spread/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/wildfire/r.spread/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -375,6 +375,35 @@
G_fatal_error(_("Raster map <%s> not found"), mois_layer);
}
+ /* Check if specified output layer names ARE LEGAL or EXISTS */
+ if (G_legal_filename(out_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), out_layer);
+
+ if (G_find_cell2(out_layer, G_mapset()))
+ G_fatal_error(
+ _("Raster map <%s> already exists in mapset <%s>, select another name"),
+ out_layer, G_mapset());
+
+ if (x_out) {
+ if (G_legal_filename(x_out_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), x_out_layer);
+
+ if (G_find_cell2(x_out_layer, G_mapset()))
+ G_fatal_error(
+ _("Raster map <%s> already exists in mapset <%s>, select another name"),
+ x_out_layer, G_mapset());
+ }
+
+ if (y_out) {
+ if (G_legal_filename(y_out_layer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), y_out_layer);
+
+ if (G_find_cell2(y_out_layer, G_mapset()))
+ G_fatal_error(
+ _("Raster map <%s> already exists in mapset <%s>, select another name"),
+ y_out_layer, G_mapset());
+ }
+
/* Open input cell layers for reading */
max_fd = G_open_cell_old(max_layer, G_find_cell2(max_layer, ""));
Modified: grass/branches/releasebranch_6_4/raster/wildfire/r.spreadpath/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/wildfire/r.spreadpath/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster/wildfire/r.spreadpath/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -258,6 +258,13 @@
else
flag = 3; /* output layer does not previously exist */
+
+ /* Check if specified output layer name is legal */
+ if (flag == 3) {
+ if (G_legal_filename(path_layer) < 0)
+ G_fatal_error("%s - illegal name", path_layer);
+ }
+
/* If the output layer containing the starting positions */
/* create a linked list of of them */
if (flag == 1) {
Modified: grass/branches/releasebranch_6_4/raster3d/r3.cross.rast/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster3d/r3.cross.rast/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster3d/r3.cross.rast/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -344,6 +344,10 @@
/**********************/
+ /*Filename check for output map */
+ if (G_legal_filename(param.output->answer) < 0)
+ fatal_error(map, elevfd, -1, _("Illegal output file name"));
+
if (G_find_cell2(param.output->answer, ""))
G_message(_("Output map already exists. Will be overwritten!"));
Modified: grass/branches/releasebranch_6_4/raster3d/r3.mkdspf/r3_find.c
===================================================================
--- grass/branches/releasebranch_6_4/raster3d/r3.mkdspf/r3_find.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster3d/r3.mkdspf/r3_find.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -33,6 +33,9 @@
char element[200], question[200];
static char dspout[200];
+ if (!G_legal_filename(dspf))
+ return (NULL);
+
if (!G_find_grid3(g3f, ""))
G_fatal_error("[%s] 3D raster map not found", g3f);
Modified: grass/branches/releasebranch_6_4/raster3d/r3.showdspf/r3_find.c
===================================================================
--- grass/branches/releasebranch_6_4/raster3d/r3.showdspf/r3_find.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster3d/r3.showdspf/r3_find.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -35,6 +35,9 @@
char element[200], question[200];
static char dspout[200];
+ if (!G_legal_filename(dspf))
+ return (NULL);
+
if (!G_find_grid3(g3f, "")) {
fprintf(stderr, "3D raster map <%s> not found\n", g3f);
return (NULL);
Modified: grass/branches/releasebranch_6_4/raster3d/r3.to.rast/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster3d/r3.to.rast/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/raster3d/r3.to.rast/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -298,6 +298,9 @@
if (fd == NULL)
fatal_error(map, NULL, 0, _("Out of memory"));
+ if (G_legal_filename(param.output->answer) < 0)
+ fatal_error(map, NULL, 0, _("Illegal output file name"));
+
G_message(_("Creating %i raster maps"), region.depths);
/*Loop over all output maps! open */
Modified: grass/branches/releasebranch_6_4/vector/v.edit/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.edit/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/vector/v.edit/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -83,6 +83,11 @@
if (action_mode == MODE_CREATE) {
int overwrite;
+ if (G_legal_filename(params.map->answer) == -1) {
+ G_fatal_error(_("<%s> is an illegal file name"),
+ params.map->answer);
+ }
+
overwrite = G_check_overwrite(argc, argv);
if (G_find_vector2(params.map->answer, G_mapset())) {
if (!overwrite)
Modified: grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/vector/v.in.ogr/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -333,6 +333,9 @@
G_fatal_error(_("Required parameter <%s> not set"), out_opt->key);
}
+ if (G_legal_filename(out_opt->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), out_opt->answer);
+
if (!outloc_opt->answer) { /* Check if the map exists */
if (G_find_vector2(out_opt->answer, G_mapset())) {
if (overwrite)
Modified: grass/branches/releasebranch_6_4/vector/v.kernel/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.kernel/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/vector/v.kernel/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -319,6 +319,10 @@
else {
/* check and open the name of output map */
if (!flag_q->answer) {
+ if (G_legal_filename(out_opt->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"),
+ out_opt->answer);
+
G_set_fp_type(DCELL_TYPE);
if ((fdout = G_open_raster_new(out_opt->answer, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
Modified: grass/branches/releasebranch_6_4/vector/v.surf.idw/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.surf.idw/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/vector/v.surf.idw/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -133,6 +133,9 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (G_legal_filename(parm.output->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), parm.output->answer);
+
if (sscanf(parm.npoints->answer, "%d", &search_points) != 1 ||
search_points < 1)
G_fatal_error(_("%s=%s - illegal number of interpolation points"),
Modified: grass/branches/releasebranch_6_4/vector/v.to.rast3/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.to.rast3/main.c 2014-05-22 03:04:11 UTC (rev 60400)
+++ grass/branches/releasebranch_6_4/vector/v.to.rast3/main.c 2014-05-22 03:10:25 UTC (rev 60401)
@@ -65,6 +65,9 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (G_legal_filename(out_opt->answer) < 0)
+ G_fatal_error(_("<%s> is an illegal file name"), out_opt->answer);
+
G3d_getWindow(®ion);
G3d_readWindow(®ion, NULL);
More information about the grass-commit
mailing list