diff options
-rw-r--r-- | vcl/source/filter/igif/gifread.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 3789ebbc8093..90f744fe69d2 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -61,6 +61,7 @@ class GIFReader : public GraphicReader Bitmap::ScopedWriteAccess pAcc1; long nYAcc; long nLastPos; + sal_uInt64 nMaxStreamData; sal_uInt32 nLogWidth100; sal_uInt32 nLogHeight100; sal_uInt16 nTimer; @@ -113,6 +114,7 @@ GIFReader::GIFReader( SvStream& rStm ) , rIStm ( rStm ) , nYAcc ( 0 ) , nLastPos ( rStm.Tell() ) + , nMaxStreamData( rStm.remainingSize() ) , nLogWidth100 ( 0UL ) , nLogHeight100 ( 0UL ) , nGlobalWidth ( 0 ) @@ -169,6 +171,20 @@ void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, } #endif + // "Overall data compression asymptotically approaches 3839 × 8 / 12 = 2559 1/3" + // so assume compression of 1:2560 is possible + // (http://cloudinary.com/blog/a_one_color_image_is_worth_two_thousand_words suggests + // 1:1472.88 [184.11 x 8] is more realistic) + const sal_uInt64 nMinFileData = nWidth * nHeight / 2560; + if (nMaxStreamData < nMinFileData) + { + //there is nowhere near enough data in this stream to fill the claimed dimensions + SAL_WARN("vcl.filter", "gif claims dimensions " << nWidth << " x " << nHeight << + " but filesize of " << nMaxStreamData << " is surely insufficiently large to fill it"); + bStatus = false; + return; + } + if( bGCTransparent ) { const Color aWhite( COL_WHITE ); |