diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-01-09 16:07:32 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-02-04 11:25:37 +0100 |
commit | 8db8184a25a16fb8736bbbbe08b71dfd7570af86 (patch) | |
tree | 84371d93dbcaa438a5bef42680b5d9f2de6bf464 /lotuswordpro | |
parent | 4cefe6119a0328a1ddbf548f707b882c7e20dd47 (diff) |
ofz#43446 Undefined-shift
Change-Id: Ibe3485983ecf764ca8b8e667b470c6b210b6d2d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128192
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 27e9de358b4afc6a89b09c173316cee0abfb471d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128234
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit fb5fe960e4d50176c754ae2d10ce53c3c3da82a1)
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/lwpdrawobj.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx index 38e8c3162f08..98b5567037e1 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) { |