desktop/inc/lib/init.hxx    |    4 +++-
 desktop/source/lib/init.cxx |   20 ++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 2c8f792bf839bd712e0301f087d339ffcc1d22f3
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed Dec 15 15:22:45 2021 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Thu Dec 16 09:33:51 2021 +0100

    ensure invalidate tiles LOK message range checking
    
    3db1ce30ab235ad22aed71c22e4f6f52b7b88829 added some range checking
    on the rectangles, such as making sure (x,y) is not less than (0,0),
    and it added it to converting string messages back to rectangles.
    But then 3b729db05553c1a6d461fb41c89a05702f407448 avoided
    the conversions from string messages back to rectangles, and thus
    it avoided also these checks.
    
    Change-Id: I73a08e418dc2e48ef5e89fe1aee0272851f7d363
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126864
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Ashod Nakashian <a...@collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 5e1e23b2cdb5..bb560264743b 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -52,7 +52,7 @@ namespace desktop {
         }
 
         RectangleAndPart(const tools::Rectangle* pRect, int nPart)
-            : m_aRectangle( pRect ? *pRect : emptyAllRectangle)
+            : m_aRectangle( pRect ? CheckedRectangle(*pRect) : 
emptyAllRectangle)
             , m_nPart(nPart)
         {
         }
@@ -81,6 +81,8 @@ namespace desktop {
         }
 
         static RectangleAndPart Create(const std::string& rPayload);
+        static tools::Rectangle CheckedRectangle(tools::Long nLeft, 
tools::Long nTop, tools::Long nWidth, tools::Long nHeight);
+        static tools::Rectangle CheckedRectangle(const tools::Rectangle& rect);
     };
 
     class DESKTOP_DLLPUBLIC CallbackFlushHandler final : public Idle, public 
SfxLokCallbackInterface
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bf4bd7883f4f..22523ecc2227 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -555,6 +555,13 @@ RectangleAndPart RectangleAndPart::Create(const 
std::string& rPayload)
         nPart = rtl_str_toInt64_WithLength(pos, 10, end - pos);
     }
 
+    aRet.m_aRectangle = CheckedRectangle(nLeft, nTop, nWidth, nHeight);
+    aRet.m_nPart = nPart;
+    return aRet;
+}
+
+tools::Rectangle RectangleAndPart::CheckedRectangle(tools::Long nLeft, 
tools::Long nTop, tools::Long nWidth, tools::Long nHeight)
+{
     if (nWidth > 0 && nHeight > 0)
     {
         // The top-left corner starts at (0, 0).
@@ -572,14 +579,15 @@ RectangleAndPart RectangleAndPart::Create(const 
std::string& rPayload)
         }
 
         if (nWidth > 0 && nHeight > 0)
-        {
-            aRet.m_aRectangle = tools::Rectangle(nLeft, nTop, nLeft + nWidth, 
nTop + nHeight);
-        }
+            return tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + 
nHeight);
     }
-    // else leave empty rect.
+    // Else set empty rect.
+    return tools::Rectangle();
+}
 
-    aRet.m_nPart = nPart;
-    return aRet;
+tools::Rectangle RectangleAndPart::CheckedRectangle(const tools::Rectangle& 
rect)
+{
+    return CheckedRectangle(rect.Left(), rect.Top(), rect.getWidth(), 
rect.getHeight());
 }
 
 const std::string& CallbackFlushHandler::CallbackData::getPayload() const

Reply via email to