r.in.erdas crashing

Jim Aanstoos (919) 541-6890 AANSTOOS%LOUIE at rcc.rti.org
Tue Jan 5 10:44:31 EST 1993

I have solved the problem I was having with r.in.erdas that I reported
on here recently, and so I thought I would share the solution in case
it might be of use to others.  The symptoms were that it crashed with
a segmentation fault when reading an erdas lan file.  The file happened
to have 10 bands in it, but no one seemed to think that should be a
problem.  I was attempting to extract only one band.
A quick look at the source code for r.in.erdas revealed the reason for
the crash:
# main.c
#define MAXBND 7
int i,n,band,erdf,pack,outband[MAXBND+1],offset;
To make a long story short, (and besides this isn't the programmers board
anyway) the array outband gets indexed by a counter incremented up to the 
number of bands read from the erdas file header, without testing or
limiting it to the MAXBND value. 
Of course the immediate solution to my need was to change the value of MAXBND 
and re-compile, but a more robust fix for general use would be to test
the value of nbands (read in from the erdas file) against  MAXBND and warn
the user rather than crashing. 
Moral to the story: if you have more than 7 bands in your Erdas file,
r.in.erdas as distributed will not handle it (even if you only want to extract a 
subset of them).

  jim /--\
     /    \ 
Jim Aanstoos                  Research Triangle Institute
Internet: aanstoos%louie at rcc.rti.org
  Bitnet: aanstoos%louie at rti.bitnet

More information about the grass-user mailing list