Opened 14 years ago

Closed 14 years ago

#3399 closed defect (fixed)

Crash in GRIB reader when file open fails

Reported by: gaige Owned by: gaige
Priority: normal Milestone: 1.7.2
Component: GDAL_Raster Version: 1.7.0
Severity: normal Keywords: grib
Cc: warmerdam

Description

The result of the file open isn't checked. Added this check

frmts/grib/gribdataset.cpp: 491a492,504

/* check return values and gracefully fail */ if (!poDS->fp) {

we have no FP, so we don't have anywhere to read from

char * errMsg = errSprintf(NULL); if( errMsg != NULL )

CPLDebug( "GRIB", "%s", errMsg );

free(errMsg);

CPLError( CE_Failure, CPLE_OpenFailed, "Error (%d) opening file %s", errno, poOpenInfo->pszFilename);

delete poDS; return NULL; }

Change History (4)

comment:1 by gaige, 14 years ago

Once more with the diff

frmts/grib/gribdataset.cpp:
491a492,504
> 	/* check return values and gracefully fail */
> 	if (!poDS->fp) {
> 		// we have no FP, so we don't have anywhere to read from
>         char * errMsg = errSprintf(NULL);
>         if( errMsg != NULL )
>             CPLDebug( "GRIB", "%s", errMsg );
>         free(errMsg);
> 		
> 		CPLError( CE_Failure, CPLE_OpenFailed, "Error (%d) opening file %s", errno, poOpenInfo->pszFilename);
>         delete poDS;
>         return NULL;
> 	}
> 	

comment:2 by warmerdam, 14 years ago

Cc: warmerdam added
Component: defaultGDAL_Raster
Keywords: grib added
Owner: changed from warmerdam to gaige

This change looks fine. I'm not certain when we would get to this point and still not be able to open the file.

comment:3 by gaige, 14 years ago

I can try and find my particular test that crashed here, but I believe it was when I did a driver-specific open on the file. However, I reached this point in the code, which is why I changed it on my source.

-Gaige

comment:4 by gaige, 14 years ago

Resolution: fixed
Status: newclosed

r20430 /gdal/trunk/frmts/grib/gribdataset.cpp : Fix Crash in GRIB reader when file open fails (#3399)

r20431 /gdal/1.7/frmts/grib/gribdataset.cpp : Fix Crash in GRIB reader when file open fails (#3399)

Note: See TracTickets for help on using tickets.