summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-23 11:01:00 +0000
committerAndras Timar <andras.timar@collabora.com>2017-03-01 13:47:42 +0100
commit2a13cc35ea3b627f89fda58d3de0a8eb1f346364 (patch)
treef3c7193e88b7ebd1ecca0343cff77571497b5aea /filter
parent4644615634482280eee6b71882f381cc1b476b8b (diff)
ofz: don't read data that isn't there
Change-Id: I7fdcb78bde8f650c1a57d34177d8993a6d8a0a2f (cherry picked from commit ee619fb344c7e8f491e09bd256df7f8567af9bef) improve scoping Change-Id: Ic79d46da4e322a0f52981c3a3df65f7f0294fdd8 (cherry picked from commit 840ad0a88045021c58644404a099a3678a371020) make this a little clearer no logic change intended Change-Id: Ibfc46d0aba9e220be54270734e0cdfbc123be9a5 (cherry picked from commit 46b1b5dd2a5368663fd56434160fa126f1a54d84) Reviewed-on: https://gerrit.libreoffice.org/34572 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit 4d31e570f69fd8ec5294ea2aea019b57637bccb9)
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/itiff/itiff.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index 96c7f0c41628..48f985e12ab6 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -786,7 +786,7 @@ sal_uLong TIFFReader::GetBits( const sal_uInt8 * pSrc, sal_uLong nBitsPos, sal_u
bool TIFFReader::ConvertScanline(sal_Int32 nY)
{
- sal_uInt32 nRed, nGreen, nBlue, ns, nVal, nByteCount;
+ sal_uInt32 nRed, nGreen, nBlue, ns, nVal;
sal_uInt8 nByteVal;
if ( nDstBitsPerPixel == 24 )
@@ -997,11 +997,18 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
case 1 :
{
+ sal_uInt32 nByteCount = nImageWidth >> 3;
+
+ sal_uInt32 nBytesNeeded = nByteCount;
+ if (nImageWidth & 7)
+ ++nBytesNeeded;
+ if (pt + nBytesNeeded > ptend)
+ return false;
+
if ( bByteSwap )
{
sal_Int32 nx = 0;
- nByteCount = ( nImageWidth >> 3 ) + 1;
- while ( --nByteCount )
+ while (nByteCount--)
{
nByteVal = *pt++;
pAcc->SetPixelIndex( nY, nx++, nByteVal & 1 );
@@ -1033,8 +1040,7 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
else
{
sal_Int32 nx = 7;
- nByteCount = ( nImageWidth >> 3 ) + 1;
- while ( --nByteCount )
+ while (nByteCount--)
{
nByteVal = *pt++;
pAcc->SetPixelIndex( nY, nx, nByteVal & 1 );