[GRASS5] Re: [bug #223] (grass) d.zoom segfaults

On Mon, 19 Mar 2001, Request Tracker wrote:

d.zoom segfaults direct after startup without any message.
region is :
CURRENT REGION: N=431250 S=350000 RES=250 ROWS=325
                   E= 80000 W= 13000 RES=250 COLS=268

It seems the bug was caused by a library call in
src/libes/gis/find_file.c. A string was copied to an empty string wich
caused the segfault.

The solution (or: my solution) is the following diff for find_file.c. I
can submit it to the CVS but I don't like to mess with libraries and I
don't know if there is a 'philosophy' behind the original method.

54c54,56
< strcpy(mapset, xmapset);
---

      if (!mapset=="") {
          strcpy(mapset, xmapset);
      }

Grtz, Job

-----------------------------------------------------------------------
Job Spijker
Faculty of Geographical Sciences, Utrecht University
-----------------------------------------------------------------------

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

spijker@geo.uu.nl wrote:

The solution (or: my solution) is the following diff for find_file.c. I
can submit it to the CVS but I don't like to mess with libraries and I
don't know if there is a 'philosophy' behind the original method.

54c54,56
< strcpy(mapset, xmapset);
---
> if (!mapset=="") {
> strcpy(mapset, xmapset);
> }

Job -- voor je submit: je voorstel is
niet geheel zonder risico's -- probeer onderstaand programmaatje x.c.

Beter is wellicht:

  if (mapset != NULL && *mapset != '\0') {
     ...
  }

Grtz,
--
Edzer

(attachments)

x.c (204 Bytes)

Sorry about my previous post -- I intended to send it to Job in
private, but overlooked the Reply-To field. Now I owe you a translation:

spijker@geo.uu.nl wrote:

The solution (or: my solution) is the following diff for find_file.c. I
can submit it to the CVS but I don't like to mess with libraries and I
don't know if there is a 'philosophy' behind the original method.

54c54,56
< strcpy(mapset, xmapset);
---
> if (!mapset=="") {
> strcpy(mapset, xmapset);
> }

Be careful about comparing mapset directly to ""; please try the
example program below to see why.

A more defensive solution might be:
   
   if (mapset != NULL && *mapset != '\0') {

(it doesn't need to know whether mapset is a character array or a
pointer to a character).
--
Edzer

(attachments)

x.c (262 Bytes)

Hi Huidae,

you changed src/libes/gis/find_file.c recently to fix the
i.in.erdas. Do you have a recommendation for below proposal
from Job?

Thanks

Markus

On Tue, Mar 20, 2001 at 01:07:01PM +0100, spijker@geo.uu.nl wrote:

On Mon, 19 Mar 2001, Request Tracker wrote:

> d.zoom segfaults direct after startup without any message.
> region is :
> CURRENT REGION: N=431250 S=350000 RES=250 ROWS=325
> E= 80000 W= 13000 RES=250 COLS=268

It seems the bug was caused by a library call in
src/libes/gis/find_file.c. A string was copied to an empty string wich
caused the segfault.

The solution (or: my solution) is the following diff for find_file.c. I
can submit it to the CVS but I don't like to mess with libraries and I
don't know if there is a 'philosophy' behind the original method.

54c54,56
< strcpy(mapset, xmapset);
---
> if (!mapset=="") {
> strcpy(mapset, xmapset);
> }

Grtz, Job

-----------------------------------------------------------------------
Job Spijker
Faculty of Geographical Sciences, Utrecht University
-----------------------------------------------------------------------

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

From neteler@geog.uni-hannover.de Wed Mar 21 02:21:02 2001
Date: Tue, 20 Mar 2001 17:45:00 +0000
From: Markus Neteler <neteler@geog.uni-hannover.de>
To: grass5@geog.uni-hannover.de
Subject: Re: [GRASS5] Re: [bug #223] (grass) d.zoom segfaults

Hi Huidae,

you changed src/libes/gis/find_file.c recently to fix the
i.in.erdas. Do you have a recommendation for below proposal
from Job?

Thanks

Markus

On Tue, Mar 20, 2001 at 01:07:01PM +0100, spijker@geo.uu.nl wrote:
> On Mon, 19 Mar 2001, Request Tracker wrote:
>
> > d.zoom segfaults direct after startup without any message.
> > region is :
> > CURRENT REGION: N=431250 S=350000 RES=250 ROWS=325
> > E= 80000 W= 13000 RES=250 COLS=268
>
>
> It seems the bug was caused by a library call in
> src/libes/gis/find_file.c. A string was copied to an empty string wich
> caused the segfault.
>
> The solution (or: my solution) is the following diff for find_file.c. I
> can submit it to the CVS but I don't like to mess with libraries and I
> don't know if there is a 'philosophy' behind the original method.
>
> 54c54,56
> < strcpy(mapset, xmapset);
> ---
> > if (!mapset=="") {
> > strcpy(mapset, xmapset);
> > }
>
>

Hi Markus,

I see. I'm correcting it. :slight_smile:

Regards,
Huidae Cho

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Hi,

Huidae has applied changes to
src/libes/gis/find_file.c
src/libes/gis/file_name.c

(for all those not listening to the CVS commits announce channel at:
Bereich Geographie – Naturwissenschaftliche Fakultät – Leibniz Universität Hannover
)

Hope this fixes the problems.

Markus

On Tue, Mar 20, 2001 at 06:32:07PM +0100, Edzer J. Pebesma wrote:

Sorry about my previous post -- I intended to send it to Job in
private, but overlooked the Reply-To field. Now I owe you a translation:

spijker@geo.uu.nl wrote:

> The solution (or: my solution) is the following diff for find_file.c. I
> can submit it to the CVS but I don't like to mess with libraries and I
> don't know if there is a 'philosophy' behind the original method.
>
> 54c54,56
> < strcpy(mapset, xmapset);
> ---
> > if (!mapset=="") {
> > strcpy(mapset, xmapset);
> > }

Be careful about comparing mapset directly to ""; please try the
example program below to see why.

A more defensive solution might be:
   
   if (mapset != NULL && *mapset != '\0') {

(it doesn't need to know whether mapset is a character array or a
pointer to a character).
--
Edzer

--
Markus Neteler * University of Hannover
Institute of Physical Geography and Landscape Ecology
Schneiderberg 50 * D-30167 Hannover * Germany
Tel: ++49-(0)511-762-4494 Fax: -3984

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'