Opened 15 years ago

Closed 15 years ago

#2751 closed defect (fixed)

GRIB driver asserts (crashes) on opening this dataset

Reported by: gaopeng Owned by: warmerdam
Priority: normal Milestone: 1.6.1
Component: GDAL_Raster Version: 1.6.0
Severity: normal Keywords: grib
Cc: rprinceley

Description (last modified by warmerdam)

GRIB driver asserts (crashes) on opening this dataset. The "nSectSize" is a large number, and the memory allocation fails.

        memcpy( &nSectSize, abyHead, 4 );
        CPL_MSBPTR32( &nSectSize );

        if( VSIFSeekL( poDS->fp, nSectSize-5, SEEK_CUR ) != 0
            || VSIFReadL( abyHead, 5, 1, poDS->fp ) != 1 )
            break;

Attachments (1)

Sample_QuikSCAT.grb (19.1 KB ) - added by gaopeng 15 years ago.

Download all attachments as: .zip

Change History (6)

by gaopeng, 15 years ago

Attachment: Sample_QuikSCAT.grb added

comment:1 by rprinceley, 15 years ago

Cc: rprinceley added

Adding myself to CC.

comment:2 by warmerdam, 15 years ago

Component: defaultGDAL_Raster
Keywords: grib added
Status: newassigned

The file works fine on my 64bit workstation but does fail with an error in CPLMalloc() allocated 1.9GB on a 32bit windows build.

Digging further.

comment:3 by warmerdam, 15 years ago

Description: modified (diff)

comment:4 by warmerdam, 15 years ago

The problem turns out to be that the PDS scanning logic in gribdataset.cpp assumed that the file was GRIB2, but GRIB1 files use a different byte ordering for section sizes. The correction is to only scan for PDS templates with GRIB 2 files. Applied in trunk (r16455) and 1.6 branch (r16456).

I have also added a minimal test with this sample file in the autotest suite (r16457).

comment:5 by warmerdam, 15 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.