summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-12-15 15:22:45 +0100
committerAndras Timar <andras.timar@collabora.com>2021-12-16 09:33:51 +0100
commit2c8f792bf839bd712e0301f087d339ffcc1d22f3 (patch)
tree2126c31eee96780f57d4d48c2009f14b5bd15fb1
parentd991e7f3ffbb689f54663cb8f44f68f895925a21 (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Ashod Nakashian <ash@collabora.com>
-rw-r--r--desktop/inc/lib/init.hxx4
-rw-r--r--desktop/source/lib/init.cxx20
2 files changed, 17 insertions, 7 deletions
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