[GRASS5] CygWIN: MinGW compilation of R/GRASS interface

Roger Bivand Roger.Bivand at nhh.no
Tue Feb 18 09:26:04 EST 2003


On Tue, 18 Feb 2003, Glynn Clements wrote:
> 
> Roger Bivand wrote:
> 
> > I've submitted GRASS_0.2-2 to CRAN, thanks for your help. One problem that 
> > I hit is that strlen() in G_store() usually crashes (MinGW and gcc RH 
> > 2.96) when passed a NULL string - a test might be an idea anyway in 
> > libes/gis/store.c.
> 
> If you know of any specific cases where NULL might be passed to
> G_store(), please report them, as they may indicate that a "not-NULL"
> check should be added to the caller.
> 
In my R_G_init.c, in function R_G_get_gisrc_file()

      gisrc = G_store(G__get_gisrc_file());

where G__get_gisrc_file() is in my modified env.c:

char *G__get_gisrc_file (void)
{
    FILE *fd;
    if (!gisrc) {
        fd = open_env("r");
        if (fd == NULL) {
		  G_warning("Failure opening GISRC file");
		  G__set_gisrc_file(NULL);
		  return gisrc;
	}
        fclose(fd);
    }

    return gisrc;
}

and the original is:


char *G__get_gisrc_file (void)
{
    return gisrc;
}

with:

static char *gisrc = NULL;

in both cases. Maybe it doesn't happen anywhere else, but I didn't expect 
strlen() to be vulnerable - I thought it would give some sensible return 
value (-1 is logical) when handed a NULL string.

Roger

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the grass-dev mailing list