From 61364e5b983acea4f8607cc74d8cc6c319a6e3a5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 30 Jan 2019 13:36:01 +0000 Subject: Resolves: tdf#122958 bmps with weird compression values that work in mso MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie1887288cba7c1d56b807dbc9ddb886b9d20ff33 Reviewed-on: https://gerrit.libreoffice.org/67143 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/source/gdi/dibtools.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index f78cbc02c03a..fd7bb4306076 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -942,6 +942,18 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL return false; break; } + default: + // tdf#122958 invalid compression value used + if (aHeader.nCompression & 0x000F) + { + // lets assume that there was an error in the generating application + // and allow through as COMPRESS_NONE if the bottom byte is 0 + SAL_WARN( "vcl", "bad bmp compression scheme: " << aHeader.nCompression << ", rejecting bmp"); + return false; + } + else + SAL_WARN( "vcl", "bad bmp compression scheme: " << aHeader.nCompression << ", assuming meant to be COMPRESS_NONE"); + [[fallthrough]]; case BITFIELDS: case ZCOMPRESS: case COMPRESS_NONE: @@ -953,8 +965,6 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL return false; break; } - default: - return false; } const Size aSizePixel(aHeader.nWidth, aHeader.nHeight); -- cgit