[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - filter/qa filter/source
Caolán McNamara
caolanm at redhat.com
Sun Jul 19 23:26:26 PDT 2015
filter/qa/cppunit/data/tiff/fail/crash-1.tiff |binary
filter/source/graphicfilter/itiff/itiff.cxx | 54 +++++++++++++-------------
2 files changed, 27 insertions(+), 27 deletions(-)
New commits:
commit 7ad4717198ff62bac51b59b13f72c301ddd81c86
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Jul 19 21:09:25 2015 +0100
in reality we are limited to max sal_Int32 here
so accept that and test if the values were accepted or limited
Change-Id: I599cf8065a6f8786d380fdba03135857766770f3
(cherry picked from commit 80c591ea9c320fee9e975ac7b0e4e2df1bf5e447)
Reviewed-on: https://gerrit.libreoffice.org/17198
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/filter/qa/cppunit/data/tiff/fail/crash-1.tiff b/filter/qa/cppunit/data/tiff/fail/crash-1.tiff
new file mode 100644
index 0000000..4fa0bb9
Binary files /dev/null and b/filter/qa/cppunit/data/tiff/fail/crash-1.tiff differ
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index c35d943..20d3768 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -66,8 +66,8 @@ private:
sal_uLong nNewSubFile;
sal_uLong nSubFile;
- sal_uLong nImageWidth; // picture width in pixels
- sal_uLong nImageLength; // picture height in pixels
+ sal_Int32 nImageWidth; // picture width in pixels
+ sal_Int32 nImageLength; // picture height in pixels
sal_uLong nBitsPerSample; // bits per pixel per layer
sal_uLong nCompression; // kind of compression
sal_uLong nPhotometricInterpretation;
@@ -119,7 +119,7 @@ private:
// Create the bitmap from the temporary bitmap pMap
// and partly deletes pMap while doing this.
- bool ConvertScanline( sal_uLong nY );
+ bool ConvertScanline(sal_Int32 nY);
// converts a Scanline to the Windows-BMP format
bool HasAlphaChannel() const;
@@ -547,13 +547,13 @@ bool TIFFReader::ReadMap( sal_uLong nMinPercent, sal_uLong nMaxPercent )
{
if ( nCompression == 1 || nCompression == 32771 )
{
- sal_uLong ny, np, nStrip, nStripBytesPerRow;
+ sal_uLong np, nStrip, nStripBytesPerRow;
if ( nCompression == 1 )
nStripBytesPerRow = nBytesPerRow;
else
nStripBytesPerRow = ( nBytesPerRow + 1 ) & 0xfffffffe;
- for ( ny = 0; ny < nImageLength; ny++ )
+ for (sal_Int32 ny = 0; ny < nImageLength; ++ny)
{
for ( np = 0; np < nPlanes; np++ )
{
@@ -572,7 +572,7 @@ bool TIFFReader::ReadMap( sal_uLong nMinPercent, sal_uLong nMaxPercent )
}
else if ( nCompression == 2 || nCompression == 3 || nCompression == 4 )
{
- sal_uLong ny, np, nStrip, nOptions;
+ sal_uLong np, nStrip, nOptions;
if ( nCompression == 2 )
{
nOptions = CCI_OPTION_BYTEALIGNROW;
@@ -607,7 +607,7 @@ bool TIFFReader::ReadMap( sal_uLong nMinPercent, sal_uLong nMaxPercent )
aCCIDecom.StartDecompression( *pTIFF );
- for ( ny = 0; ny < nImageLength; ny++ )
+ for (sal_Int32 ny = 0; ny < nImageLength; ++ny)
{
for ( np = 0; np < nPlanes; np++ )
{
@@ -634,13 +634,13 @@ bool TIFFReader::ReadMap( sal_uLong nMinPercent, sal_uLong nMaxPercent )
else if ( nCompression == 5 )
{
LZWDecompressor aLZWDecom;
- sal_uLong ny, np, nStrip;
+ sal_uLong np, nStrip;
nStrip=0;
if ( nStrip >= nNumStripOffsets )
return false;
pTIFF->Seek(pStripOffsets[nStrip]);
aLZWDecom.StartDecompression(*pTIFF);
- for ( ny = 0; ny < nImageLength; ny++ )
+ for (sal_Int32 ny = 0; ny < nImageLength; ++ny)
{
for ( np = 0; np < nPlanes; np++ )
{
@@ -664,13 +664,13 @@ bool TIFFReader::ReadMap( sal_uLong nMinPercent, sal_uLong nMaxPercent )
}
else if ( nCompression == 32773 )
{
- sal_uLong nStrip,nRecCount,nRowBytesLeft,ny,np,i;
+ sal_uLong nStrip,nRecCount,nRowBytesLeft,np,i;
sal_uInt8 * pdst;
nStrip = 0;
if ( nStrip >= nNumStripOffsets )
return false;
pTIFF->Seek(pStripOffsets[nStrip]);
- for ( ny = 0; ny < nImageLength; ny++ )
+ for (sal_Int32 ny = 0; ny < nImageLength; ++ny)
{
for ( np = 0; np < nPlanes; np++ )
{
@@ -785,9 +785,9 @@ sal_uLong TIFFReader::GetBits( const sal_uInt8 * pSrc, sal_uLong nBitsPos, sal_u
-bool TIFFReader::ConvertScanline( sal_uLong nY )
+bool TIFFReader::ConvertScanline(sal_Int32 nY)
{
- sal_uInt32 nRed, nGreen, nBlue, ns, nx, nVal, nByteCount;
+ sal_uInt32 nRed, nGreen, nBlue, ns, nVal, nByteCount;
sal_uInt8 nByteVal;
if ( nDstBitsPerPixel == 24 )
@@ -804,7 +804,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
sal_uInt8 nLGreen = 0;
sal_uInt8 nLBlue = 0;
sal_uInt8 nLAlpha = 0;
- for ( nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel )
+ for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel)
{
nLRed = nLRed + pt[ 0 ];
nLGreen = nLGreen + pt[ 1 ];
@@ -819,7 +819,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
}
else
{
- for ( nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel )
+ for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel)
{
pAcc->SetPixel( nY, nx, Color( pt[0], pt[1], pt[2] ) );
if (nSamplesPerPixel >= 4 && pMaskAcc)
@@ -835,7 +835,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
if ( nMaxSampleValue > nMinSampleValue )
{
sal_uLong nMinMax = nMinSampleValue * 255 / ( nMaxSampleValue - nMinSampleValue );
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
if ( nPlanes < 3 )
{
@@ -858,7 +858,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
if ( nMaxSampleValue > nMinSampleValue )
{
sal_uLong nMinMax = nMinSampleValue * 255 / ( nMaxSampleValue - nMinSampleValue );
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
if ( nPlanes < 3 )
{
@@ -887,7 +887,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
sal_uInt8 nSampLast[ 4 ] = { 0, 0, 0, 0 };
long nBlack;
- for( nx = 0; nx < nImageWidth; nx++ )
+ for(sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
// are the values being saved as difference?
if( 2 == nPredictor )
@@ -940,7 +940,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
if ( nPredictor == 2 )
{
sal_uInt8 nLast = 0;
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
nLast += nx == 0 ? BYTESWAP( (sal_uInt8)*pt++ ) : *pt++;
pAcc->SetPixelIndex( nY, nx, nLast );
@@ -948,7 +948,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
}
else
{
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
sal_uInt8 nLast = *pt++;
pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>( (BYTESWAP((sal_uLong)nLast) - nMinSampleValue) * nMinMax ) );
@@ -960,7 +960,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
if ( nPredictor == 2 )
{
sal_uInt8 nLast = 0;
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
nLast += *pt++;
pAcc->SetPixelIndex( nY, nx, nLast );
@@ -968,7 +968,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
}
else
{
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>( ((sal_uLong)*pt++ - nMinSampleValue) * nMinMax ) );
@@ -985,7 +985,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
case 3 :
case 2 :
{
- for ( nx = 0; nx < nImageWidth; nx++ )
+ for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
{
nVal = ( GetBits( pt, nx * nBitsPerSample, nBitsPerSample ) - nMinSampleValue ) * nMinMax;
pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>(nVal));
@@ -997,7 +997,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
{
if ( bByteSwap )
{
- nx = 0;
+ sal_Int32 nx = 0;
nByteCount = ( nImageWidth >> 3 ) + 1;
while ( --nByteCount )
{
@@ -1030,7 +1030,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
}
else
{
- nx = 7;
+ sal_Int32 nx = 7;
nByteCount = ( nImageWidth >> 3 ) + 1;
while ( --nByteCount )
{
@@ -1078,7 +1078,7 @@ bool TIFFReader::ConvertScanline( sal_uLong nY )
{
sal_uLong nMinMax = ( ( 1 << 8 /*nDstBitsPerPixel*/ ) - 1 ) / ( nMaxSampleValue - nMinSampleValue );
sal_uInt8* pt = pMap[ 0 ];
- for ( nx = 0; nx < nImageWidth; nx++, pt += 2 )
+ for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += 2 )
{
pAcc->SetPixelIndex( nY, nx, static_cast<sal_uInt8>( ((sal_uLong)*pt - nMinSampleValue) * nMinMax) );
}
@@ -1340,7 +1340,7 @@ bool TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic )
Size aTargetSize( nImageWidth, nImageLength );
aBitmap = Bitmap( aTargetSize, nDstBitsPerPixel );
pAcc = aBitmap.AcquireWriteAccess();
- if ( pAcc )
+ if (pAcc && pAcc->Width() == nImageWidth && pAcc->Height() == nImageLength)
{
if ( nPlanarConfiguration == 1 )
nPlanes = 1;
More information about the Libreoffice-commits
mailing list