diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-16 16:35:41 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-03-16 20:38:29 +0000 |
commit | ea8a1bda453ed63d9b26b01f29b0701828dde77c (patch) | |
tree | 52eedc774158d3c8d9d28067b7204b33738970e9 /vcl | |
parent | 5885a5da36828434bc80c6dde0334f74f1de1195 (diff) |
ofz#882: test available len against max possible compression
Change-Id: I19867b74d860f379eae17916cc7f6415e6d20074
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/pngread.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index 6cf9828f682b..09bbc66b695b 100644 --- a/vcl/source/gdi/pngread.cxx +++ b/vcl/source/gdi/pngread.cxx @@ -596,6 +596,16 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint ) if ( nScansize64 > SAL_MAX_UINT32 ) return false; + // assume max theoretical compression of 1:1032 + sal_uInt64 nMinSizeRequired = (nScansize64 * maOrigSize.Height()) / 1032; + if (nMinSizeRequired > mnStreamSize) + { + SAL_WARN("vcl.gdi", "overlarge png dimensions: " << + maOrigSize.Width() << " x " << maOrigSize.Height() << " depth: " << (int)mnPngDepth << + " couldn't be supplied by file length " << mnStreamSize << " at least " << nMinSizeRequired << " needed "); + return false; + } + mnScansize = static_cast< sal_uInt32 >( nScansize64 ); // calculate target size from original size and the preview hint |