desktop/inc/lib/init.hxx | 5 ++++- desktop/source/lib/init.cxx | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-)
New commits: commit 672c6d74b027fc7731afb959599ffea77d6ae2ba Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Dec 15 15:22:45 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Thu Dec 16 15:21:18 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/+/126865 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 1ba7e54ff976..636cf8ef9863 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -53,7 +53,7 @@ namespace desktop { } RectangleAndPart(const tools::Rectangle* pRect, int nPart) - : m_aRectangle( pRect ? *pRect : emptyAllRectangle) + : m_aRectangle( pRect ? SanitizedRectangle(*pRect) : emptyAllRectangle) , m_nPart(nPart) { } @@ -82,6 +82,9 @@ namespace desktop { } static RectangleAndPart Create(const std::string& rPayload); + /// Makes sure a rectangle is valid (apparently some code does not like negative coordinates for example). + static tools::Rectangle SanitizedRectangle(tools::Long nLeft, tools::Long nTop, tools::Long nWidth, tools::Long nHeight); + static tools::Rectangle SanitizedRectangle(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 3be80637ec26..434c7d80e01e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -557,6 +557,13 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload) nPart = rtl_str_toInt64_WithLength(pos, 10, end - pos); } + aRet.m_aRectangle = SanitizedRectangle(nLeft, nTop, nWidth, nHeight); + aRet.m_nPart = nPart; + return aRet; +} + +tools::Rectangle RectangleAndPart::SanitizedRectangle(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). @@ -574,14 +581,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::SanitizedRectangle(const tools::Rectangle& rect) +{ + return SanitizedRectangle(rect.Left(), rect.Top(), rect.getWidth(), rect.getHeight()); } const std::string& CallbackFlushHandler::CallbackData::getPayload() const