Opened 13 years ago

Last modified 13 years ago

#1446 closed defect (fixed)

MrSID driver fails when decoding strip data

Reported by: mchapman Owned by: 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 (6)

comment:1 Changed 13 years ago 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!

comment:2 Changed 13 years ago 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;

}

comment:3 Changed 13 years ago by mchapman

This has been fixed, tested and comitted to SVN.

comment:4 Changed 13 years ago by warmerdam

Patch back ported into 1.4 branch. 


comment:7 Changed 13 years ago by hobu

Description: modified (diff)
Milestone: 1.4.1

comment:8 Changed 13 years ago by hobu

Version: unspecified1.4.0
Note: See TracTickets for help on using tickets.