[Libreoffice-commits] core.git: 2 commits - filter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 13 06:27:20 UTC 2018
filter/source/graphicfilter/itiff/itiff.cxx | 11 +++++++----
filter/source/msfilter/escherex.cxx | 11 +++++++++--
2 files changed, 16 insertions(+), 6 deletions(-)
New commits:
commit 4bf2b13647030d4e5a44d6a23d5570aeea70c333
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Nov 12 21:22:03 2018 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Nov 13 07:27:08 2018 +0100
Clamp equation values when exporting to binary MS format
CppunitTest_sw_ooxmlexport failed under
-fsanitize=implicit-signed-integer-truncation when writing 100000 (from the
triangle equation in oox/source/drawingml/customshapes/oox-drawingml-cs-presets)
as a 16-bit value (see below), and as discussed at FreeNode #libreoffice-dev:
Nov 12 09:12:32 <vmiklos> sberg: ah, that's custom shape equation, read from
ooxml but then written to ms binary format; i'm not sure if there is a better
option there other than just clamping the value.
Nov 12 09:14:33 <vmiklos> sberg: i would expect that information is 1) used in
general when writing drawingml+vml markup for a shape (where the vml fallback
is not read by LO nor by MSO) and 2) i don't expect that our poor vml export
actually reads those equations. so the vml export builds on top of the binary
export, but at the end probably that information (equations) is not read by
anyone
(At least for CppunitTest_sw_ooxmlexport, equation.nPara[1] never needed such
clamping, just nPara[0] and nPara[2].)
> filter/source/msfilter/escherex.cxx:2929:50: runtime error: implicit conversion from type 'sal_Int32' (aka 'int') of value 100000 (32-bit, signed) to type 'sal_Int16' (aka 'short') changed the value to -31072 (16-bit, signed)
> #0 in EscherPropertyContainer::CreateCustomShapeProperties(MSO_SPT, com::sun::star::uno::Reference<com::sun::star::drawing::XShape> const&) at filter/source/msfilter/escherex.cxx:2929:50 (instdir/program/libmsfilterlo.so +0x54f1e6)
> #1 in ImplEESdrWriter::ImplWriteShape(ImplEESdrObject&, EscherSolverContainer&, bool) at filter/source/msfilter/eschesdo.cxx:283:26 (instdir/program/libmsfilterlo.so +0x67a775)
> #2 in ImplEESdrWriter::ImplWriteTheShape(ImplEESdrObject&, bool) at filter/source/msfilter/eschesdo.cxx:932:12 (instdir/program/libmsfilterlo.so +0x69059d)
> #3 in EscherEx::AddSdrObject(SdrObject const&, bool) at filter/source/msfilter/eschesdo.cxx:951:35 (instdir/program/libmsfilterlo.so +0x691064)
> #4 in oox::vml::VMLExport::AddSdrObject(SdrObject const&, short, short, short, short, bool) at oox/source/export/vmlexport.cxx:1425:15 (instdir/program/libooxlo.so +0x2ab3157)
> #5 in DocxSdrExport::writeVMLDrawing(SdrObject const*, SwFrameFormat const&) at sw/source/filter/ww8/docxsdrexport.cxx:772:38 (instdir/program/libmswordlo.so +0x168bfb2)
> #6 in DocxSdrExport::writeDMLAndVMLDrawing(SdrObject const*, SwFrameFormat const&, int) at sw/source/filter/ww8/docxsdrexport.cxx:975:9 (instdir/program/libmswordlo.so +0x16938f5)
> #7 in DocxAttributeOutput::OutputFlyFrame_Impl(ww8::Frame const&, Point const&) at sw/source/filter/ww8/docxattributeoutput.cxx:5357:57 (instdir/program/libmswordlo.so +0x1371a67)
> #8 in AttributeOutputBase::OutputFlyFrame(ww8::Frame const&) at sw/source/filter/ww8/wrtw8nds.cxx:3173:5 (instdir/program/libmswordlo.so +0x1befe5a)
> #9 in SwWW8AttrIter::OutFlys(int) at sw/source/filter/ww8/wrtw8nds.cxx:667:41 (instdir/program/libmswordlo.so +0x1beeb70)
> #10 in MSWordExportBase::OutputTextNode(SwTextNode&) at sw/source/filter/ww8/wrtw8nds.cxx:2275:42 (instdir/program/libmswordlo.so +0x1c32e4d)
> #11 in MSWordExportBase::OutputContentNode(SwContentNode&) at sw/source/filter/ww8/wrtw8nds.cxx:3237:13 (instdir/program/libmswordlo.so +0x1c5c7e4)
> #12 in MSWordExportBase::WriteText() at sw/source/filter/ww8/wrtww8.cxx:2725:13 (instdir/program/libmswordlo.so +0x1efcdc2)
> #13 in DocxExport::WriteMainText() at sw/source/filter/ww8/docxexport.cxx:1453:5 (instdir/program/libmswordlo.so +0x1607d1f)
> #14 in DocxExport::ExportDocument_Impl() at sw/source/filter/ww8/docxexport.cxx:514:5 (instdir/program/libmswordlo.so +0x1604baf)
> #15 in MSWordExportBase::ExportDocument(bool) at sw/source/filter/ww8/wrtww8.cxx:3206:19 (instdir/program/libmswordlo.so +0x1f3f022)
> #16 in DocxExportFilter::exportDocument() at sw/source/filter/ww8/docxexportfilter.cxx:86:17 (instdir/program/libmswordlo.so +0x166b5e3)
> #17 in oox::core::FilterBase::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at oox/source/core/filterbase.cxx:489:55 (instdir/program/libooxlo.so +0x1bc3880)
> #18 in WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at writerfilter/source/filter/WriterFilter.cxx:144:23 (instdir/program/libwriterfilterlo.so +0x1a250bf)
> #19 in SfxObjectShell::ExportTo(SfxMedium&) at sfx2/source/doc/objstor.cxx:2441:25 (instdir/program/libsfxlo.so +0x38d1352)
> #20 in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) at sfx2/source/doc/objstor.cxx:1535:19 (instdir/program/libsfxlo.so +0x38c1818)
> #21 in SfxObjectShell::PreDoSaveAs_Impl(rtl::OUString const&, rtl::OUString const&, SfxItemSet const&) at sfx2/source/doc/objstor.cxx:2848:39 (instdir/program/libsfxlo.so +0x38f0e90)
> #22 in SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objstor.cxx:2705:9 (instdir/program/libsfxlo.so +0x38ea470)
> #23 in SfxObjectShell::APISaveAs_Impl(rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objserv.cxx:308:19 (instdir/program/libsfxlo.so +0x38667e3)
> #24 in SfxBaseModel::impl_store(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, bool) at sfx2/source/doc/sfxbasemodel.cxx:2969:46 (instdir/program/libsfxlo.so +0x3a3c48e)
> #25 in SfxBaseModel::storeToURL(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at sfx2/source/doc/sfxbasemodel.cxx:1639:13 (instdir/program/libsfxlo.so +0x3a425d5)
> #26 in SwModelTestBase::reload(char const*, char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:797:20 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlexport.so +0x364711)
> #27 in SwModelTestBase::executeImportExportImportTest(char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:283:9 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlexport.so +0x362d08)
> #28 in testTextboxTable::Import_Export_Import() at sw/qa/extras/ooxmlexport/ooxmlexport.cxx:559:1 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlexport.so +0x43c8dd)
[...]
Change-Id: I21d028af121691d51b053c1bf9e49c656be62b77
Reviewed-on: https://gerrit.libreoffice.org/63309
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index ecffc34b4cb0..a41f5c1d9be9 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -19,6 +19,7 @@
#include "eschesdo.hxx"
#include <o3tl/any.hxx>
+#include <o3tl/clamp.hxx>
#include <o3tl/make_unique.hxx>
#include <svx/svdxcgv.hxx>
#include <svx/svdomedia.hxx>
@@ -2926,9 +2927,15 @@ void EscherPropertyContainer::CreateCustomShapeProperties( const MSO_SPT eShapeT
for (auto const& equation : aEquations)
{
aMemStrm.WriteUInt16( equation.nOperation )
- .WriteInt16( equation.nPara[ 0 ] )
+ .WriteInt16(
+ o3tl::clamp(
+ equation.nPara[ 0 ], sal_Int32(SAL_MIN_INT16),
+ sal_Int32(SAL_MAX_INT16)) )
.WriteInt16( equation.nPara[ 1 ] )
- .WriteInt16( equation.nPara[ 2 ] );
+ .WriteInt16(
+ o3tl::clamp(
+ equation.nPara[ 2 ], sal_Int32(SAL_MIN_INT16),
+ sal_Int32(SAL_MAX_INT16)) );
}
AddOpt(DFF_Prop_pFormulas, true, 6, aMemStrm);
commit f4f3e7919de9d632881e3bca5eba9499450bfaf4
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Nov 12 21:18:16 2018 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Nov 13 07:26:57 2018 +0100
Silence -fsanitize=implicit-signed-integer-truncation
...as happens during CppunitTest_sw_ooxmlimport2:
> filter/source/graphicfilter/itiff/itiff.cxx:866:29: runtime error: implicit conversion from type 'int' of value 498 (32-bit, signed) to type 'sal_uInt8' (aka 'unsigned char') changed the value to 242 (8-bit, unsigned)
> #0 in TIFFReader::ConvertScanline(int) at filter/source/graphicfilter/itiff/itiff.cxx:866:29 (instdir/program/libgielo.so +0x294419)
> #1 in TIFFReader::ReadMap() at filter/source/graphicfilter/itiff/itiff.cxx:695:19 (instdir/program/libgielo.so +0x292291)
> #2 in TIFFReader::ReadTIFF(SvStream&, Graphic&) at filter/source/graphicfilter/itiff/itiff.cxx:1597:32 (instdir/program/libgielo.so +0x2ac5c5)
> #3 in itiGraphicImport at filter/source/graphicfilter/itiff/itiff.cxx:1673:28 (instdir/program/libgielo.so +0x2af1ed)
> #4 in GraphicFilter::ImportGraphic(Graphic&, rtl::OUString const&, SvStream&, unsigned short, unsigned short*, GraphicFilterImportFlags, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>*, WmfExternal const*) at vcl/source/filter/graphicfilter.cxx:2031:22 (instdir/program/libvcllo.so +0x684e246)
> #5 in GraphicFilter::ImportGraphic(Graphic&, rtl::OUString const&, SvStream&, unsigned short, unsigned short*, GraphicFilterImportFlags, WmfExternal const*) at vcl/source/filter/graphicfilter.cxx:1281:12 (instdir/program/libvcllo.so +0x6845817)
> #6 in (anonymous namespace)::GraphicProvider::queryGraphic(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at vcl/source/graphic/UnoGraphicProvider.cxx:418:33 (instdir/program/libvcllo.so +0x623ca3a)
> #7 in non-virtual thunk to (anonymous namespace)::GraphicProvider::queryGraphic(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at vcl/source/graphic/UnoGraphicProvider.cxx (instdir/program/libvcllo.so +0x62407e2)
> #8 in oox::GraphicHelper::importGraphic(com::sun::star::uno::Reference<com::sun::star::io::XInputStream> const&, WmfExternal const*) const at oox/source/helper/graphichelper.cxx:263:39 (instdir/program/libooxlo.so +0x2b33a1f)
> #9 in oox::GraphicHelper::importEmbeddedGraphic(rtl::OUString const&, WmfExternal const*) const at oox/source/helper/graphichelper.cxx:351:24 (instdir/program/libooxlo.so +0x2b370da)
> #10 in oox::drawingml::BlipContext::BlipContext(oox::core::ContextHandler2Helper const&, oox::AttributeList const&, oox::drawingml::BlipFillProperties&) at oox/source/drawingml/misccontexts.cxx:154:72 (instdir/program/libooxlo.so +0x23c35e0)
> #11 in oox::drawingml::BlipFillContext::onCreateContext(int, oox::AttributeList const&) at oox/source/drawingml/misccontexts.cxx:237:24 (instdir/program/libooxlo.so +0x23c6da4)
> #12 in non-virtual thunk to oox::drawingml::BlipFillContext::onCreateContext(int, oox::AttributeList const&) at oox/source/drawingml/misccontexts.cxx (instdir/program/libooxlo.so +0x23c8638)
> #13 in oox::core::ContextHandler2Helper::implCreateChildContext(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at oox/source/core/contexthandler2.cxx:94:34 (instdir/program/libooxlo.so +0x1b877e4)
> #14 in oox::core::ContextHandler2::createFastChildContext(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at oox/source/core/contexthandler2.cxx:191:12 (instdir/program/libooxlo.so +0x1b8a37c)
> #15 in non-virtual thunk to oox::core::ContextHandler2::createFastChildContext(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at oox/source/core/contexthandler2.cxx (instdir/program/libooxlo.so +0x1b8a3c8)
> #16 in writerfilter::ooxml::OOXMLFastContextHandlerWrapper::lcl_createFastChildContext(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:1908:31 (instdir/program/libwriterfilterlo.so +0x1ade3d6)
> #17 in writerfilter::ooxml::OOXMLFastContextHandler::createFastChildContext(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:208:21 (instdir/program/libwriterfilterlo.so +0x1aa7c37)
> #18 in non-virtual thunk to writerfilter::ooxml::OOXMLFastContextHandler::createFastChildContext(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at writerfilter/source/ooxml/OOXMLFastContextHandler.cxx (instdir/program/libwriterfilterlo.so +0x1aa7ed8)
> #19 in (anonymous namespace)::Entity::startElement((anonymous namespace)::Event const*) at sax/source/fastparser/fastparser.cxx:439:44 (instdir/program/libexpwraplo.so +0x24df0c)
> #20 in sax_fastparser::FastSaxParserImpl::callbackStartElement(unsigned char const*, unsigned char const*, unsigned char const*, int, unsigned char const**, int, unsigned char const**) at sax/source/fastparser/fastparser.cxx:1254:21 (instdir/program/libexpwraplo.so +0x24943f)
> #21 in (anonymous namespace)::call_callbackStartElement(void*, unsigned char const*, unsigned char const*, unsigned char const*, int, unsigned char const**, int, int, unsigned char const**) at sax/source/fastparser/fastparser.cxx:310:18 (instdir/program/libexpwraplo.so +0x240f8e)
> #22 in xmlParseStartTag2 at workdir/UnpackedTarball/libxml2/parser.c:9583:6 (instdir/program/libxml2.so.2 +0x6f8f90)
> #23 in xmlParseTryOrFinish at workdir/UnpackedTarball/libxml2/parser.c:11342:14 (instdir/program/libxml2.so.2 +0x73005c)
> #24 in xmlParseChunk__internal_alias at workdir/UnpackedTarball/libxml2/parser.c:12244:13 (instdir/program/libxml2.so.2 +0x7241ea)
> #25 in sax_fastparser::FastSaxParserImpl::parse() at sax/source/fastparser/fastparser.cxx:1061:21 (instdir/program/libexpwraplo.so +0x23e2e4)
> #26 in sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource const&) at sax/source/fastparser/fastparser.cxx:870:9 (instdir/program/libexpwraplo.so +0x237beb)
> #27 in sax_fastparser::FastSaxParser::parseStream(com::sun::star::xml::sax::InputSource const&) at sax/source/fastparser/fastparser.cxx:1377:13 (instdir/program/libexpwraplo.so +0x2528ab)
> #28 in writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) at writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:503:22 (instdir/program/libwriterfilterlo.so +0x1a69417)
> #29 in WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at writerfilter/source/filter/WriterFilter.cxx:186:24 (instdir/program/libwriterfilterlo.so +0x1a25e0b)
> #30 in SfxObjectShell::ImportFrom(SfxMedium&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) at sfx2/source/doc/objstor.cxx:2251:34 (instdir/program/libsfxlo.so +0x38dc7ff)
> #31 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:772:23 (instdir/program/libsfxlo.so +0x38a5979)
> #32 in SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at sfx2/source/doc/sfxbasemodel.cxx:1795:36 (instdir/program/libsfxlo.so +0x3a47e1e)
> #33 in (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) at sfx2/source/view/frmload.cxx:688:28 (instdir/program/libsfxlo.so +0x40c92b0)
> #34 in framework::LoadEnv::impl_loadContent() at framework/source/loadenv/loadenv.cxx:1149:37 (instdir/program/libfwklo.so +0x1521191)
> #35 in framework::LoadEnv::startLoading() at framework/source/loadenv/loadenv.cxx:383:20 (instdir/program/libfwklo.so +0x1511b76)
> #36 in framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at framework/source/loadenv/loadenv.cxx:169:14 (instdir/program/libfwklo.so +0x150d828)
> #37 in framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at framework/source/services/desktop.cxx:619:12 (instdir/program/libfwklo.so +0x167057e)
> #38 in non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at framework/source/services/desktop.cxx (instdir/program/libfwklo.so +0x167078a)
> #39 in unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at unotest/source/cpp/macros_test.cxx:50:60 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x8f176)
> #40 in SwModelTestBase::loadURL(rtl::OUString const&, char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:762:23 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlimport2.so +0x1256b1)
> #41 in SwModelTestBase::load(rtl::OUString const&, char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:717:16 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlimport2.so +0x123fd6)
> #42 in SwModelTestBase::executeImportTest(char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:264:13 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlimport2.so +0x1236bf)
> #43 in testTdf115094::Import() at sw/qa/extras/ooxmlimport/ooxmlimport2.cxx:226:1 (workdir/LinkTarget/CppunitTest/libtest_sw_ooxmlimport2.so +0x18e87d)
[...]
Change-Id: I04bf52ac9ee45d5bfefe2a406d9c601112baeef9
Reviewed-on: https://gerrit.libreoffice.org/63307
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index a2b8ddb06ae8..d2bb00e3720f 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -863,13 +863,16 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
sal_uInt8 nLAlpha = 0;
for (sal_Int32 nx = 0; nx < nImageWidth; nx++, pt += nSamplesPerPixel)
{
- nLRed = nLRed + pt[ 0 ];
- nLGreen = nLGreen + pt[ 1 ];
- nLBlue = nLBlue + pt[ 2 ];
+ // The following computations rely on sal_uInt8 wrap-around when adding the
+ // (unsigned) pt deltas; the "& 0xFF" is only conceptual, but helps prevent
+ // sanitizer warnings:
+ nLRed = (nLRed + pt[ 0 ]) & 0xFF;
+ nLGreen = (nLGreen + pt[ 1 ]) & 0xFF;
+ nLBlue = (nLBlue + pt[ 2 ]) & 0xFF;
SetPixel(nY, nx, Color(nLRed, nLGreen, nLBlue));
if (HasAlphaChannel())
{
- nLAlpha = nLAlpha + pt[ 3 ];
+ nLAlpha = (nLAlpha + pt[ 3 ]) & 0xFF;
SetPixelAlpha(nY, nx, ~nLAlpha);
}
}
More information about the Libreoffice-commits
mailing list