[Libreoffice-commits] core.git: sc/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 2 21:39:36 UTC 2020


 sc/source/filter/excel/xlescher.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 3577292de9eb751e4e3c2f799ad22b6ee9f04038
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 2 21:42:21 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Sep 2 23:38:52 2020 +0200

    Avoid UBSan negative double -> unsigned int conversion
    
    ...during CppunitTest_sc_subsequent_export_test:
    
    > /sc/source/filter/excel/xlescher.cxx:116:43: runtime error: -764.94 is outside the range of representable values of type 'unsigned int'
    >     #0 0x2b30c609bf3b in (anonymous namespace)::lclGetRowFromY(ScDocument const&, short, unsigned int&, unsigned int&, unsigned int, unsigned int, long&, long, double) /sc/source/filter/excel/xlescher.cxx:116:43
    >     #1 0x2b30c609b1ff in XclObjAnchor::SetRect(XclRoot const&, short, tools::Rectangle const&, MapUnit) /sc/source/filter/excel/xlescher.cxx:174:5
    >     #2 0x2b30c4e4c027 in XclExpDffSheetAnchor::ImplCalcAnchorRect(tools::Rectangle const&, MapUnit) /sc/source/filter/excel/xeescher.cxx:308:14
    >     #3 0x2b30c4e4b4f4 in XclExpDffAnchorBase::WriteData(EscherEx&, tools::Rectangle const&) /sc/source/filter/excel/xeescher.cxx:277:5
    >     #4 0x2b306e07562c in EscherExHostAppData::WriteClientAnchor(EscherEx&, tools::Rectangle const&) /include/filter/msfilter/escherex.hxx:958:51
    >     #5 0x2b306e14480f in ImplEESdrWriter::ImplWriteShape(ImplEESdrObject&, EscherSolverContainer&, bool) /filter/source/msfilter/eschesdo.cxx:677:28
    >     #6 0x2b306e14cabe in ImplEESdrWriter::ImplWritePage(EscherSolverContainer&) /filter/source/msfilter/eschesdo.cxx:827:13
    >     #7 0x2b306e14e881 in ImplEESdrWriter::ImplWriteCurrentPage() /filter/source/msfilter/eschesdo.cxx:909:5
    >     #8 0x2b306e14ed51 in EscherEx::AddSdrPage(SdrPage const&) /filter/source/msfilter/eschesdo.cxx:922:28
    >     #9 0x2b30c4e89c21 in XclExpObjectManager::ProcessDrawing(SdrPage const*) /sc/source/filter/excel/xeescher.cxx:1807:21
    >     #10 0x2b30c4831460 in ExcTable::FillAsTableXml() /sc/source/filter/excel/excdoc.cxx:630:47
    >     #11 0x2b30c4837c43 in ExcDocument::ReadDoc() /sc/source/filter/excel/excdoc.cxx:747:23
    >     #12 0x2b30c5463fac in XclExpXmlStream::exportDocument() /sc/source/filter/excel/xestream.cxx:1103:18
    >     #13 0x2b3070c004e4 in oox::core::FilterBase::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /oox/source/core/filterbase.cxx:492:49
    >     #14 0x2b30c670399c in oox::xls::ExcelFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /sc/source/filter/oox/excelfilter.cxx:235:27
    >     #15 0x2b3091e831fb in SfxObjectShell::ExportTo(SfxMedium&) /sfx2/source/doc/objstor.cxx:2451:25
    >     #16 0x2b3091e7237c in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) /sfx2/source/doc/objstor.cxx:1543:19
    >     #17 0x2b3091e856ff in SfxObjectShell::DoSaveAs(SfxMedium&) /sfx2/source/doc/objstor.cxx:1922:17
    >     #18 0x2b308e173ff9 in ScBootstrapFixture::saveAndReload(ScDocShell*, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags) /sc/qa/unit/helper/qahelper.cxx:677:13
    >     #19 0x2b308e17632f in ScBootstrapFixture::saveAndReload(ScDocShell*, int) /sc/qa/unit/helper/qahelper.cxx:699:28
    >     #20 0x2b3067b71c92 in ScExportTest::testTdf135828_Shape_Rect() /sc/qa/unit/subsequent_export-test.cxx:5289:28
    
    (see
    <https://lists.freedesktop.org/archives/libreoffice/2020-August/085797.html>
    "[global-libreoffice-ci] UBSAN Linux Build - Build # 1738 - Failure!")  As an
    uneducated guess, restrict the rnOffset value to >= 0 on the basis that both
    Calc and Excel reportedly require drawing elements to have non-negative
    positions.
    
    Change-Id: If687b467421437a6b448060fdbc3206b83917c40
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101979
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx
index 44549430f53a..a2c24a1c9aaa 100644
--- a/sc/source/filter/excel/xlescher.cxx
+++ b/sc/source/filter/excel/xlescher.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <algorithm>
+
 #include <xlescher.hxx>
 
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -113,7 +117,7 @@ void lclGetRowFromY(
     }
     if( !bFound )
         rnXclRow = nXclMaxRow;
-    rnOffset = static_cast< sal_uInt32 >( nRowH ? ((nTwipsY - rnStartH) * 256.0 / nRowH + 0.5) : 0 );
+    rnOffset = static_cast< sal_uInt32 >( nRowH ? std::max((nTwipsY - rnStartH) * 256.0 / nRowH + 0.5, 0.0) : 0 );
 }
 
 /** Mirrors a rectangle (from LTR to RTL layout or vice versa). */


More information about the Libreoffice-commits mailing list