Ticket #1446 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

MrSID driver fails when decoding strip data

Reported by: mchapman Assigned to: mchapman
Priority: high Milestone: 1.4.1
Component: GDAL_Raster Version: 1.4.0
Severity: normal Keywords:
Cc:

Description (Last modified by hobu)

In MrSIDDummyImageReader::decodeStrip() sometimes the request to stripData.importDataBSQ() can fail from a buffer overrun error.  The problem is that the wrong dimensions are used to allocate the data buffer for RasterIO().  The fix is to get the Y size from the stripData.getTotalNumRows() method instead of the stripScene.getNumRows() method.

Change History

01/18/07 11:42:47 changed by warmerdam

Martin,

Could you apply this in subversion?  I'll review it, and then backport
into the 1.4 branch if it looks good to me. 

Thanks!

01/18/07 16:52:43 changed by mchapman

Frank,

Here is the code for review.  I will also apply to subversion.  This fix has been validated as "passed" by our testing team.  That doesn't guarantee that is is flawless but it should be pretty good.

/************************************************************************/

/*                             decodeStrip()                            */

/************************************************************************/

 

LT_STATUS MrSIDDummyImageReader::decodeStrip(LTISceneBuffer& stripData,

                                             const LTIScene& stripScene)

{

    const lt_int32  nXOff = stripScene.getUpperLeftCol();

    const lt_int32  nYOff = stripScene.getUpperLeftRow();

    const lt_int32  nBufXSize = stripScene.getNumCols();

    const lt_int32  nBufYSize = stripScene.getNumRows();

    const lt_int32  nDataBufXSize = stripData.getTotalNumCols();

    const lt_int32  nDataBufYSize = stripData.getTotalNumRows();

             const lt_uint16 nBands = poPixel->getNumBands();

 

    void    *pData = CPLMalloc(nDataBufXSize * nDataBufYSize * poPixel->getNumBytes());

    if ( !pData )

    {

        CPLError( CE_Failure, CPLE_AppDefined,

                  "MrSIDDummyImageReader::decodeStrip(): "

                  "Cannot allocate enough space for scene buffer" );

        return LT_STS_Failure;

    }

 

    poDS->RasterIO( GF_Read, nXOff, nYOff, nBufXSize, nBufYSize, 

                    pData, nBufXSize, nBufYSize, eDataType, nBands, NULL, 

                    0, 0, 0 );

    stripData.importDataBSQ( pData );

 

    CPLFree( pData );

 

    return LT_STS_Success;

}

01/18/07 17:34:18 changed by mchapman

This has been fixed, tested and comitted to SVN.

01/18/07 21:10:52 changed by warmerdam

Patch back ported into 1.4 branch. 


03/25/07 20:30:29 changed by hobu

  • description changed.
  • milestone set to 1.4.1.

03/25/07 20:30:44 changed by hobu

  • version changed from unspecified to 1.4.0.