Abort out early when reading the "A" record if it doesn't look like
a proper DEM file.
This commit is contained in:
parent
5880cd9ec0
commit
317854534f
2 changed files with 20 additions and 4 deletions
18
DEM/dem.cxx
18
DEM/dem.cxx
|
@ -198,7 +198,7 @@ static int next_exp(gzFile fd) {
|
||||||
|
|
||||||
|
|
||||||
// read and parse DEM "A" record
|
// read and parse DEM "A" record
|
||||||
void fgDEM::read_a_record( void ) {
|
int fgDEM::read_a_record( void ) {
|
||||||
int i, inum;
|
int i, inum;
|
||||||
double dnum;
|
double dnum;
|
||||||
char name[144];
|
char name[144];
|
||||||
|
@ -225,6 +225,10 @@ void fgDEM::read_a_record( void ) {
|
||||||
inum = next_int(fd);
|
inum = next_int(fd);
|
||||||
printf(" DEM level code = %d\n", inum);
|
printf(" DEM level code = %d\n", inum);
|
||||||
|
|
||||||
|
if ( inum > 3 ) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Pattern code, 1 indicates a regular elevation pattern
|
// Pattern code, 1 indicates a regular elevation pattern
|
||||||
inum = next_int(fd);
|
inum = next_int(fd);
|
||||||
printf(" Pattern code = %d\n", inum);
|
printf(" Pattern code = %d\n", inum);
|
||||||
|
@ -331,6 +335,8 @@ void fgDEM::read_a_record( void ) {
|
||||||
// number of profiles
|
// number of profiles
|
||||||
dem_num_profiles = cols = next_int(fd);
|
dem_num_profiles = cols = next_int(fd);
|
||||||
printf(" Expecting %d profiles\n", dem_num_profiles);
|
printf(" Expecting %d profiles\n", dem_num_profiles);
|
||||||
|
|
||||||
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,7 +383,9 @@ int fgDEM::parse( void ) {
|
||||||
|
|
||||||
cur_col = 0;
|
cur_col = 0;
|
||||||
|
|
||||||
read_a_record();
|
if ( !read_a_record() ) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
for ( i = 0; i < dem_num_profiles; i++ ) {
|
for ( i = 0; i < dem_num_profiles; i++ ) {
|
||||||
// printf("Ready to read next b record\n");
|
// printf("Ready to read next b record\n");
|
||||||
|
@ -391,7 +399,7 @@ int fgDEM::parse( void ) {
|
||||||
|
|
||||||
printf(" Done parsing\n");
|
printf(" Done parsing\n");
|
||||||
|
|
||||||
return(0);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -772,6 +780,10 @@ fgDEM::~fgDEM( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.7 1998/06/05 18:14:39 curt
|
||||||
|
// Abort out early when reading the "A" record if it doesn't look like
|
||||||
|
// a proper DEM file.
|
||||||
|
//
|
||||||
// Revision 1.6 1998/05/02 01:49:21 curt
|
// Revision 1.6 1998/05/02 01:49:21 curt
|
||||||
// Fixed a bug where the wrong variable was being initialized.
|
// Fixed a bug where the wrong variable was being initialized.
|
||||||
//
|
//
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
int parse( void );
|
int parse( void );
|
||||||
|
|
||||||
// read and parse DEM "A" record
|
// read and parse DEM "A" record
|
||||||
void read_a_record( void );
|
int read_a_record( void );
|
||||||
|
|
||||||
// read and parse DEM "B" record
|
// read and parse DEM "B" record
|
||||||
void read_b_record( void );
|
void read_b_record( void );
|
||||||
|
@ -130,6 +130,10 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.6 1998/06/05 18:14:40 curt
|
||||||
|
// Abort out early when reading the "A" record if it doesn't look like
|
||||||
|
// a proper DEM file.
|
||||||
|
//
|
||||||
// Revision 1.5 1998/04/22 13:14:46 curt
|
// Revision 1.5 1998/04/22 13:14:46 curt
|
||||||
// Fixed a bug in zlib usage.
|
// Fixed a bug in zlib usage.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Reference in a new issue