[GRASS-SVN] r41880 - in grass/trunk: imagery/i.group include
lib/imagery
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 15 17:32:26 EDT 2010
Author: huhabla
Date: 2010-04-15 17:32:25 -0400 (Thu, 15 Apr 2010)
New Revision: 41880
Modified:
grass/trunk/imagery/i.group/main.c
grass/trunk/include/imagedefs.h
grass/trunk/lib/imagery/loc_info.c
Log:
Removed unused I_location_info() from i.group (ticket #1039). Modified
I_location_info() to avoid buffer overflows.
Modified: grass/trunk/imagery/i.group/main.c
===================================================================
--- grass/trunk/imagery/i.group/main.c 2010-04-15 19:06:24 UTC (rev 41879)
+++ grass/trunk/imagery/i.group/main.c 2010-04-15 21:32:25 UTC (rev 41880)
@@ -39,7 +39,6 @@
int main(int argc, char *argv[])
{
- char title[80];
char group[GNAME_MAX], mapset[GMAPSET_MAX];
int m, k = 0;
@@ -102,9 +101,6 @@
if (k < 1 && !l->answer) /* remove if input is requirement */
G_fatal_error(_("No input raster map(s) specified"));
-
- I_location_info(title, argv[0]); /* unused? */
-
/* check if current mapset: (imagery libs are very lacking in this dept)
- abort if not,
- remove @mapset part if it is
Modified: grass/trunk/include/imagedefs.h
===================================================================
--- grass/trunk/include/imagedefs.h 2010-04-15 19:06:24 UTC (rev 41879)
+++ grass/trunk/include/imagedefs.h 2010-04-15 21:32:25 UTC (rev 41880)
@@ -59,7 +59,7 @@
int I_list_subgroup_simple(const struct Ref *, FILE *);
/* loc_info.c */
-int I_location_info(char *, const char *);
+char *I_location_info(const char *);
/* points.c */
int I_new_control_point(struct Control_Points *, double, double, double,
Modified: grass/trunk/lib/imagery/loc_info.c
===================================================================
--- grass/trunk/lib/imagery/loc_info.c 2010-04-15 19:06:24 UTC (rev 41879)
+++ grass/trunk/lib/imagery/loc_info.c 2010-04-15 21:32:25 UTC (rev 41880)
@@ -3,16 +3,19 @@
#include <grass/gis.h>
/* makes a three part title with location, mapset info */
-int I_location_info(char *buf, const char *middle)
+char *I_location_info(const char *middle)
{
char left[80];
char right[80];
- int len;
+ char *buf;
+ int len, buf_len;
- sprintf(left, "LOCATION: %s", G_location());
- sprintf(right, "MAPSET: %s", G_mapset());
+ G_snprintf(left, 80, "LOCATION: %s", G_location());
+ G_snprintf(right, 80, "MAPSET: %s", G_mapset());
len = 79 - strlen(left) - strlen(middle) - strlen(right);
- sprintf(buf, "%s%*s%s%*s%s",
+ buf_len = len + strlen(left) + strlen(middle) + strlen(right);
+ buf = (char*)G_calloc(buf_len, sizeof(char));
+ G_snprintf(buf, buf_len, "%s%*s%s%*s%s",
left, len / 2, "", middle, len / 2, "", right);
return 0;
More information about the grass-commit
mailing list