Opened 17 years ago

Last modified 17 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 by warmerdam, 17 years ago

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 by mchapman, 17 years ago

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 by mchapman, 17 years ago

This has been fixed, tested and comitted to SVN.

comment:4 by warmerdam, 17 years ago

Patch back ported into 1.4 branch. 


comment:7 by hobu, 17 years ago

Description: modified (diff)
Milestone: 1.4.1

comment:8 by hobu, 17 years ago

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