lotuswordpro/source/filter/lwpdrawobj.cxx |  121 +++++++++++++++---------------
 1 file changed, 64 insertions(+), 57 deletions(-)

New commits:
commit 9c7083250d1774a02cee0c79bd1100006668196d
Author:     zhutyra <zhutyra>
AuthorDate: Tue Feb 1 13:54:55 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:24:22 2022 +0100

    read of width/height uses wrong record size
    
    this initially went wrong at:
    
    commit b4fb7a437bb0ce987702b12008737756623618ac
    Date:   Mon May 23 21:38:40 2011 +0100
    
        fix up some more endian
    
    LIBREOFFICE-SBQ5TJRS
    
    Change-Id: Ie418f530f55288351f73f3c0cbab9ac48e6b6964
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129259
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 6694e3ea9c2f05a20245d94c5c1eda955cb3aacc)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index c76691bb760a..742e38f82c24 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1394,8 +1394,12 @@ void LwpDrawBitmap::Read()
 
     if (aInfoHeader2.nHeaderLen == sizeof(BmpInfoHeader))
     {
-        m_pStream->ReadUInt32( aInfoHeader2.nWidth );
-        m_pStream->ReadUInt32( aInfoHeader2.nHeight );
+        sal_uInt16 nTmp;
+
+        m_pStream->ReadUInt16( nTmp );
+        aInfoHeader2.nWidth = nTmp;
+        m_pStream->ReadUInt16( nTmp );
+        aInfoHeader2.nHeight = nTmp;
         m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
         m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
 
commit bd6bcffad7fe359ec98498ecc528dec9509cb615
Author:     zhutyra <zhutyra>
AuthorDate: Tue Feb 1 14:07:26 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:24:11 2022 +0100

    ensure bounds checking
    
    LIBREOFFICE-SBQ5TJRS
    
    Change-Id: I71f35bc120fdd70298685131f29a6bb822d50f11
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129261
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 17dd787a4ca9c17883e0bdfc75c89c2fa7ec169e)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index cb5c342a0aee..c76691bb760a 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1375,21 +1375,20 @@ void LwpDrawBitmap::Read()
     m_pStream->ReadUInt16( m_aBmpRec.nTranslation );
     m_pStream->ReadUInt16( m_aBmpRec.nRotation );
 
+    // 20 == length of draw-specific fields.
     if (m_aObjHeader.nRecLen < 20)
         throw BadRead();
 
-    // 20 == length of draw-specific fields.
-    // 14 == length of bmp file header.
-    m_aBmpRec.nFileSize = m_aObjHeader.nRecLen - 20 + 14;
+    sal_uInt64 nBmpPos = m_pStream->Tell();
+    sal_uInt64 nBmpLen =
+        std::min<sal_uInt64>(m_aObjHeader.nRecLen - 20, 
m_pStream->remainingSize());
 
     BmpInfoHeader2 aInfoHeader2;
     m_pStream->ReadUInt32( aInfoHeader2.nHeaderLen );
 
-    if (!m_pStream->good())
+    if (!m_pStream->good() || nBmpLen < aInfoHeader2.nHeaderLen)
         throw BadRead();
 
-    m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] );
-
     sal_uInt32 N;
     sal_uInt32 rgbTableSize;
 
@@ -1413,7 +1412,7 @@ void LwpDrawBitmap::Read()
             rgbTableSize = 3 * (1 << N);
         }
     }
-    else
+    else if (aInfoHeader2.nHeaderLen >= sizeof(BmpInfoHeader2))
     {
         m_pStream->ReadUInt32( aInfoHeader2.nWidth );
         m_pStream->ReadUInt32( aInfoHeader2.nHeight );
@@ -1432,9 +1431,15 @@ void LwpDrawBitmap::Read()
         {
             rgbTableSize = 4 * (1 << N);
         }
-
+    }
+    else
+    {
+        throw BadRead();
     }
 
+    m_aBmpRec.nFileSize = static_cast<sal_uInt32>(nBmpLen + 14);
+    m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] );
+
     sal_uInt32 nOffBits = 14 + aInfoHeader2.nHeaderLen + rgbTableSize;
     m_pImageData[0] = 'B';
     m_pImageData[1] = 'M';
@@ -1451,50 +1456,10 @@ void LwpDrawBitmap::Read()
     m_pImageData[12] = static_cast<sal_uInt8>(nOffBits >> 16);
     m_pImageData[13] = static_cast<sal_uInt8>(nOffBits >> 24);
 
-    sal_uInt32 nDIBRemaining;
     sal_uInt8* pPicData = m_pImageData.get();
-    if (aInfoHeader2.nHeaderLen== sizeof(BmpInfoHeader))
-    {
-        m_pImageData[14] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen);
-        m_pImageData[15] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 
8);
-        m_pImageData[16] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 
16);
-        m_pImageData[17] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 
24);
-        m_pImageData[18] = static_cast<sal_uInt8>(aInfoHeader2.nWidth);
-        m_pImageData[19] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 8);
-        m_pImageData[20] = static_cast<sal_uInt8>(aInfoHeader2.nHeight);
-        m_pImageData[21] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 8);
-        m_pImageData[22] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes);
-        m_pImageData[23] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes >> 8);
-        m_pImageData[24] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount);
-        m_pImageData[25] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount >> 8);
-
-        nDIBRemaining = m_aBmpRec.nFileSize - 26;
-        pPicData += 26*sizeof(sal_uInt8);
-    }
-    else
-    {
-        m_pImageData[14] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen);
-        m_pImageData[15] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 
8);
-        m_pImageData[16] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 
16);
-        m_pImageData[17] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen >> 
24);
-        m_pImageData[18] = static_cast<sal_uInt8>(aInfoHeader2.nWidth);
-        m_pImageData[19] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 8);
-        m_pImageData[20] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 16);
-        m_pImageData[21] = static_cast<sal_uInt8>(aInfoHeader2.nWidth >> 24);
-        m_pImageData[22] = static_cast<sal_uInt8>(aInfoHeader2.nHeight);
-        m_pImageData[23] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 8);
-        m_pImageData[24] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 16);
-        m_pImageData[25] = static_cast<sal_uInt8>(aInfoHeader2.nHeight >> 24);
-        m_pImageData[26] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes);
-        m_pImageData[27] = static_cast<sal_uInt8>(aInfoHeader2.nPlanes >> 8);
-        m_pImageData[28] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount);
-        m_pImageData[29] = static_cast<sal_uInt8>(aInfoHeader2.nBitCount >> 8);
-
-        nDIBRemaining = m_aBmpRec.nFileSize - 30;
-        pPicData += 30*sizeof(sal_uInt8);
-    }
 
-    if (nDIBRemaining != m_pStream->ReadBytes(pPicData, nDIBRemaining))
+    m_pStream->Seek(nBmpPos);
+    if (nBmpLen != m_pStream->ReadBytes(pPicData + 14, nBmpLen))
         throw BadRead();
 }
 
commit f88120cd4fc714a1381ccb177f5fd0ca44cd3621
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Jan 13 16:57:48 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:23:58 2022 +0100

    ofz#43577 valid reclen must be >= 20
    
    Change-Id: I454bff4acfcd85701a7f094a8bd76898825e9ce2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128388
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 444477a07bcaf59181dbbc719b913566091deadc)
    
    ofz: Use-of-uninitialized-value
    
    Change-Id: I6b768b80d972c5379005efecfb803463ca648b4b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128644
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 7b37a1a5144a3a4c8b0803b7e2da81e9e108bf66)
    
    ofz: Undefined-Shift
    
    Change-Id: Ib935359071ef9e390aa3d6c9713ed48241ad18e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129066
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit e863b90a0e5fc90c3b824e4b0012f9389b87a3ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129183
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 7c8b41bc322720dc9434fbef1f10a6740913165e)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index e0a642a12a6c..cb5c342a0aee 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1375,14 +1375,21 @@ void LwpDrawBitmap::Read()
     m_pStream->ReadUInt16( m_aBmpRec.nTranslation );
     m_pStream->ReadUInt16( m_aBmpRec.nRotation );
 
+    if (m_aObjHeader.nRecLen < 20)
+        throw BadRead();
+
     // 20 == length of draw-specific fields.
     // 14 == length of bmp file header.
     m_aBmpRec.nFileSize = m_aObjHeader.nRecLen - 20 + 14;
-    m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] );
 
     BmpInfoHeader2 aInfoHeader2;
     m_pStream->ReadUInt32( aInfoHeader2.nHeaderLen );
 
+    if (!m_pStream->good())
+        throw BadRead();
+
+    m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] );
+
     sal_uInt32 N;
     sal_uInt32 rgbTableSize;
 
@@ -1397,7 +1404,7 @@ void LwpDrawBitmap::Read()
             throw BadRead();
 
         N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
-        if (N == 24)
+        if (N >= 16)
         {
             rgbTableSize = 0;
         }
@@ -1417,7 +1424,7 @@ void LwpDrawBitmap::Read()
             throw BadRead();
 
         N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
-        if (N == 24)
+        if (N >= 16)
         {
             rgbTableSize = 0;
         }
commit 0217be216ea47efa321c5b6c880e1e6fe4232492
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Jan 17 10:48:12 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:23:49 2022 +0100

    ofz: Use-of-uninitialized-value
    
    Change-Id: Ic5f41e4f1f6b20a8cd8887807296f33adb48b728
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128439
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit bb03203848ef1c30786ad084440b5d317a466127)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index 37a14012622d..e0a642a12a6c 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1487,7 +1487,8 @@ void LwpDrawBitmap::Read()
         pPicData += 30*sizeof(sal_uInt8);
     }
 
-    m_pStream->ReadBytes(pPicData, nDIBRemaining);
+    if (nDIBRemaining != m_pStream->ReadBytes(pPicData, nDIBRemaining))
+        throw BadRead();
 }
 
 OUString LwpDrawBitmap::RegisterStyle()
commit dbb53be78910ec7377bec876793b9c9d6ccf56a7
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Jan 26 11:57:13 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:23:39 2022 +0100

    ofz#44080 throw exception on a negative length
    
    Change-Id: I3e2286cea69908fae3a2dd177d10fca2b7f0c877
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128956
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit af8709defeb90464c8724d3fe5fb8cbbf6efc2b8)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index d902fd258a8b..37a14012622d 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1092,6 +1092,9 @@ XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& 
rStyleName )
         aEncoding = LwpCharSetMgr::GetTextCharEncoding();
     }
 
+    if (TextLength < 2)
+        throw BadRead();
+
     XFParagraph* pXFPara = new XFParagraph();
     pXFPara->Add(OUString(reinterpret_cast<char*>(m_aTextRec.pTextString), 
(TextLength-2), aEncoding));
     pXFPara->SetStyleName(rStyleName);
commit 98d7589c22fed5a588fd7bf6b8eb9e0ab455e4cc
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Jan 16 14:30:15 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:23:29 2022 +0100

    ofz: Use-of-uninitialized-value
    
    Change-Id: Ib1c3b306573dda073f6ff3d7d0cc17aef39c0a0e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128436
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 7607a7e45a1da570dda0a4b96c08405086a647b6)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index 426577dfcda4..d902fd258a8b 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -499,7 +499,7 @@ void LwpDrawPolyLine::Read()
     m_pStream->ReadUChar( m_aPolyLineRec.aPenColor.unused );
     m_pStream->ReadUInt16( m_aPolyLineRec.nNumPoints );
 
-    if (m_aPolyLineRec.nNumPoints > m_pStream->remainingSize() / 4)
+    if (!m_pStream->good() || m_aPolyLineRec.nNumPoints > 
m_pStream->remainingSize() / 4)
         throw BadRead();
 
     m_pVector.reset( new SdwPoint[m_aPolyLineRec.nNumPoints] );
@@ -579,7 +579,7 @@ void LwpDrawPolygon::Read()
     ReadClosedObjStyle();
     m_pStream->ReadUInt16( m_nNumPoints );
 
-    if (m_nNumPoints > m_pStream->remainingSize() / 4)
+    if (!m_pStream->good() || m_nNumPoints > m_pStream->remainingSize() / 4)
         throw BadRead();
 
     m_pVector.reset( new SdwPoint[m_nNumPoints] );
@@ -1043,6 +1043,9 @@ void LwpDrawTextBox::Read()
     m_pStream->ReadInt16( m_aTextRec.nTextRotation );
     m_pStream->ReadInt16( m_aTextRec.nTextExtraSpacing );
 
+    if (!m_pStream->good())
+        throw BadRead();
+
     // some draw files in version 1.2 have an extra byte following '\0'.
     // can't rely on that, so read in the whole string into memory.
 
@@ -1194,17 +1197,17 @@ void LwpDrawTextArt::Read()
     m_pStream->ReadInt16( m_aTextArtRec.nRotation );
 
     sal_uInt16 nPointNumber;
-    sal_Int16 nX, nY;
     m_pStream->ReadUInt16( nPointNumber );
 
     size_t nPoints = nPointNumber*3+1;
-    if (nPoints > m_pStream->remainingSize() / 4)
+    if (!m_pStream->good() || nPoints > m_pStream->remainingSize() / 4)
         throw BadRead();
 
     m_aTextArtRec.aPath[0].n = nPointNumber;
     m_aTextArtRec.aPath[0].pPts = new SdwPoint[nPoints];
     for (size_t nPt = 0; nPt < nPoints; ++nPt)
     {
+        sal_Int16 nX, nY;
         m_pStream->ReadInt16( nX );
         m_pStream->ReadInt16( nY );
         m_aTextArtRec.aPath[0].pPts[nPt].x = nX;
@@ -1214,13 +1217,14 @@ void LwpDrawTextArt::Read()
     m_pStream->ReadUInt16( nPointNumber );
 
     nPoints = nPointNumber*3+1;
-    if (nPoints > m_pStream->remainingSize() / 4)
+    if (!m_pStream->good() || nPoints > m_pStream->remainingSize() / 4)
         throw BadRead();
 
     m_aTextArtRec.aPath[1].n = nPointNumber;
     m_aTextArtRec.aPath[1].pPts = new SdwPoint[nPoints];
     for (size_t nPt = 0; nPt < nPoints; ++nPt)
     {
+        sal_Int16 nX, nY;
         m_pStream->ReadInt16( nX );
         m_pStream->ReadInt16( nY );
         m_aTextArtRec.aPath[1].pPts[nPt].x = nX;
@@ -1248,7 +1252,7 @@ void LwpDrawTextArt::Read()
                                                     - 
(m_aTextArtRec.aPath[1].n*3 + 1)*4;
 
 
-    if (m_aTextArtRec.nTextLen > m_pStream->remainingSize())
+    if (!m_pStream->good() || m_aTextArtRec.nTextLen > 
m_pStream->remainingSize())
         throw BadRead();
 
     m_aTextArtRec.pTextString = new sal_uInt8 [m_aTextArtRec.nTextLen];
@@ -1386,7 +1390,7 @@ void LwpDrawBitmap::Read()
         m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
         m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
 
-        if (!IsValid(aInfoHeader2))
+        if (!m_pStream->good() || !IsValid(aInfoHeader2))
             throw BadRead();
 
         N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
@@ -1406,7 +1410,7 @@ void LwpDrawBitmap::Read()
         m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
         m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
 
-        if (!IsValid(aInfoHeader2))
+        if (!m_pStream->good() || !IsValid(aInfoHeader2))
             throw BadRead();
 
         N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
commit 1d269b9dde324a774fff244afa6023db9a9f9e95
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Jan 9 16:07:32 2022 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 3 12:23:15 2022 +0100

    ofz#43446 Undefined-shift
    
    Change-Id: Ibe3485983ecf764ca8b8e667b470c6b210b6d2d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128192
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 27e9de358b4afc6a89b09c173316cee0abfb471d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128234
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit fb5fe960e4d50176c754ae2d10ce53c3c3da82a1)

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx 
b/lotuswordpro/source/filter/lwpdrawobj.cxx
index f2c226a7d767..426577dfcda4 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1344,6 +1344,22 @@ LwpDrawBitmap::~LwpDrawBitmap()
 {
 }
 
+static bool IsValid(const BmpInfoHeader2& rHeader)
+{
+    if (rHeader.nPlanes != 1)
+        return false;
+
+    if (rHeader.nBitCount != 0 && rHeader.nBitCount != 1 &&
+        rHeader.nBitCount != 4 && rHeader.nBitCount != 8 &&
+        rHeader.nBitCount != 16 && rHeader.nBitCount != 24 &&
+        rHeader.nBitCount != 32)
+    {
+        return false;
+    }
+
+    return true;
+}
+
 /**
  * @descr   reading function of class LwpDrawBitmap
  */
@@ -1370,6 +1386,9 @@ void LwpDrawBitmap::Read()
         m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
         m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
 
+        if (!IsValid(aInfoHeader2))
+            throw BadRead();
+
         N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
         if (N == 24)
         {
@@ -1386,6 +1405,10 @@ void LwpDrawBitmap::Read()
         m_pStream->ReadUInt32( aInfoHeader2.nHeight );
         m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
         m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
+
+        if (!IsValid(aInfoHeader2))
+            throw BadRead();
+
         N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
         if (N == 24)
         {

Reply via email to