[GRASS-SVN] r45757 - in grass/branches/releasebranch_6_4/lib: ogsf
symbol vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 26 06:53:54 EDT 2011
Author: marisn
Date: 2011-03-26 03:53:54 -0700 (Sat, 26 Mar 2011)
New Revision: 45757
Modified:
grass/branches/releasebranch_6_4/lib/ogsf/GVL2.c
grass/branches/releasebranch_6_4/lib/ogsf/gv.c
grass/branches/releasebranch_6_4/lib/symbol/read.c
grass/branches/releasebranch_6_4/lib/vector/Vlib/dbcolumns.c
Log:
Fix possible pointer and sprintf abuse (reported by cppcheck)
Modified: grass/branches/releasebranch_6_4/lib/ogsf/GVL2.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/ogsf/GVL2.c 2011-03-26 10:22:29 UTC (rev 45756)
+++ grass/branches/releasebranch_6_4/lib/ogsf/GVL2.c 2011-03-26 10:53:54 UTC (rev 45757)
@@ -297,10 +297,10 @@
*rows = gvl->rows;
*cols = gvl->cols;
*depths = gvl->depths;
- }
- G_debug(3, "GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d",
+ G_debug(3, "GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d",
gvl->gvol_id, gvl->rows, gvl->cols, gvl->depths);
+ }
return;
}
Modified: grass/branches/releasebranch_6_4/lib/ogsf/gv.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/ogsf/gv.c 2011-03-26 10:22:29 UTC (rev 45756)
+++ grass/branches/releasebranch_6_4/lib/ogsf/gv.c 2011-03-26 10:53:54 UTC (rev 45757)
@@ -181,11 +181,11 @@
{
int i;
- G_debug(5, "gv_set_defaults() id=%d", gv->gvect_id);
-
if (!gv) {
return (-1);
}
+
+ G_debug(5, "gv_set_defaults() id=%d", gv->gvect_id);
gv->filename = NULL;
gv->n_lines = gv->n_surfs = gv->use_mem = 0;
Modified: grass/branches/releasebranch_6_4/lib/symbol/read.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/symbol/read.c 2011-03-26 10:22:29 UTC (rev 45756)
+++ grass/branches/releasebranch_6_4/lib/symbol/read.c 2011-03-26 10:53:54 UTC (rev 45757)
@@ -216,7 +216,7 @@
{
fclose(fp);
G_free(s); /* TODO: free all */
- G_warning(msg);
+ G_warning("%s", msg);
return NULL;
}
@@ -231,7 +231,7 @@
{
int i, j, k, l;
FILE *fp;
- char group[500], name[500], buf[2001];
+ char group[500], name[500], buf[2001], temp_buf[2001];
char *ms, *c;
double x, y, x2, y2, rad, ang1, ang2;
int r, g, b;
@@ -342,8 +342,8 @@
sscanf(data, "%lf %lf %lf %lf %lf %c", &x, &y, &rad, &ang1,
&ang2, &clock);
if (ret < 5) {
- sprintf(buf, "Incorrect arc definition: '%s'", buf);
- return (err(fp, symb, buf));
+ sprintf(temp_buf, "Incorrect arc definition: '%s'", buf);
+ return (err(fp, symb, temp_buf));
}
if (ret == 6 && (clock == 'c' || clock == 'C'))
i = 1;
@@ -426,8 +426,8 @@
}
}
else {
- sprintf(buf, "Unknown keyword in symbol: '%s'", buf);
- return (err(fp, symb, buf));
+ sprintf(temp_buf, "Unknown keyword in symbol: '%s'", buf);
+ return (err(fp, symb, temp_buf));
break;
}
}
Modified: grass/branches/releasebranch_6_4/lib/vector/Vlib/dbcolumns.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/Vlib/dbcolumns.c 2011-03-26 10:22:29 UTC (rev 45756)
+++ grass/branches/releasebranch_6_4/lib/vector/Vlib/dbcolumns.c 2011-03-26 10:53:54 UTC (rev 45757)
@@ -45,7 +45,7 @@
dbHandle handle;
dbString table_name;
dbTable *table;
- char buf[2000];
+ char buf[2000], temp_buf[2000];
num_dblinks = Vect_get_num_dblinks(Map);
@@ -75,9 +75,11 @@
if (col == 0)
sprintf(buf, "%s",
db_get_column_name(db_get_table_column(table, col)));
- else
- sprintf(buf, "%s,%s", buf,
+ else {
+ sprintf(temp_buf, ",%s",
db_get_column_name(db_get_table_column(table, col)));
+ strcat(buf, temp_buf);
+ }
}
G_debug(3, "%s", buf);
@@ -104,7 +106,7 @@
dbHandle handle;
dbString table_name;
dbTable *table;
- char buf[2000];
+ char buf[2000], temp_buf[2000];
num_dblinks = Vect_get_num_dblinks(Map);
@@ -135,10 +137,12 @@
sprintf(buf, "%s",
db_sqltype_name(db_get_column_sqltype
(db_get_table_column(table, col))));
- else
- sprintf(buf, "%s,%s", buf,
+ else {
+ sprintf(temp_buf, ",%s",
db_sqltype_name(db_get_column_sqltype
(db_get_table_column(table, col))));
+ strcat(buf, temp_buf);
+ }
}
G_debug(3, "%s", buf);
@@ -166,7 +170,7 @@
dbHandle handle;
dbString table_name;
dbTable *table;
- char buf[2000];
+ char buf[2000], temp_buf[2000];
num_dblinks = Vect_get_num_dblinks(Map);
@@ -198,11 +202,13 @@
db_get_column_name(db_get_table_column(table, col)),
db_sqltype_name(db_get_column_sqltype
(db_get_table_column(table, col))));
- else
- sprintf(buf, "%s,%s(%s)", buf,
+ else {
+ sprintf(temp_buf, ",%s(%s)",
db_get_column_name(db_get_table_column(table, col)),
db_sqltype_name(db_get_column_sqltype
(db_get_table_column(table, col))));
+ strcat(buf, temp_buf);
+ }
}
G_debug(3, "%s", buf);
More information about the grass-commit
mailing list