sw/source/filter/ww8/ww8atr.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 15aa055adfb8e52d593a3302e283ec15b03900ff
Author:     Jonathan Clark <jonat...@libreoffice.org>
AuthorDate: Wed Mar 19 03:41:58 2025 -0600
Commit:     Jonathan Clark <jonat...@libreoffice.org>
CommitDate: Wed Mar 19 13:06:44 2025 +0100

    Fix ubsan out-of-range int in DOC export with CJK hanging indentation
    
    As seen in:
    
    > /include/o3tl/safeint.hxx:227:78: runtime error: -200 is outside the 
range of representable values of type 'unsigned short'
    >    #0 0x7f8cd335b5ec in unsigned short o3tl::narrowing<unsigned short, 
double>(double) /include/o3tl/safeint.hxx:227:78
    >    #1 0x7f8cd341698c in 
WW8AttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const&) 
/sw/source/filter/ww8/ww8atr.cxx:4358:32
    
    during CppunitTest_sw_ww8export4::testTdf80596Hanging
    (<https://ci.libreoffice.org/job/lo_ubsan/3500/>)
    
    sprmPDxc* attributes contain signed 16-bit integers, as they may
    correctly be negative in the case of hanging indentation. However, they
    were previously serialized as if unsigned.
    
    Change-Id: Id7f6ed465876d5c471ad3ed5c37134db98b0f8c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183122
    Tested-by: Jenkins
    Reviewed-by: Jonathan Clark <jonat...@libreoffice.org>

diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 3b3efccfbbe3..db29159a5c7e 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4355,7 +4355,7 @@ void 
WW8AttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFi
     {
         // sprmPDxcLeft1
         m_rWW8Export.InsUInt16(0x4457);
-        m_rWW8Export.InsUInt16(o3tl::narrowing<sal_uInt16>(stOffset.m_dValue * 
100.0));
+        m_rWW8Export.InsInt16(o3tl::narrowing<sal_Int16>(stOffset.m_dValue * 
100.0));
     }
     else
     {
@@ -4386,7 +4386,7 @@ void 
WW8AttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rText
 
         // sprmPDxcLeft
         m_rWW8Export.InsUInt16(0x4456);
-        m_rWW8Export.InsUInt16(o3tl::narrowing<sal_uInt16>(stOffset.m_dValue * 
100.0));
+        m_rWW8Export.InsInt16(o3tl::narrowing<sal_Int16>(stOffset.m_dValue * 
100.0));
     }
     else
     {
@@ -4403,7 +4403,7 @@ void 
WW8AttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargi
     {
         // sprmPDxcRight
         m_rWW8Export.InsUInt16(0x4455);
-        m_rWW8Export.InsUInt16(o3tl::narrowing<sal_uInt16>(stOffset.m_dValue * 
100.0));
+        m_rWW8Export.InsInt16(o3tl::narrowing<sal_Int16>(stOffset.m_dValue * 
100.0));
     }
     else
     {

Reply via email to