kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0019-lokdocview-check-payload-for-inconsistencies-before-.patch

135360
From b049bfd09192d01aa5dcbc48975cf9eb3e1997b9 Mon Sep 17 00:00:00 2001
135360
From: Pranav Kant <pranavk@gnome.org>
135360
Date: Fri, 5 Jun 2015 17:06:54 +0530
135360
Subject: [PATCH 019/398] lokdocview: check payload for inconsistencies before
135360
 using it
135360
135360
Lets follow the old advice: "Be liberal in what you accept, be strict in
135360
what you produce".
135360
135360
This is after noticing negative values for x, y in
135360
the payload in some situation, such as, hitting a backspace key when the
135360
cursor is at the start of a line
135360
135360
Change-Id: I11939b981f75969b88214baee66b4c69c5e41906
135360
(cherry picked from commit 35e03615066a6525e0259ff1823a0da0c2d4820a)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 12 ++++++++++--
135360
 1 file changed, 10 insertions(+), 2 deletions(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index 48b3ed6e2080..d9e8c14aa9d5 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -187,9 +187,9 @@ struct LOKDocView_Impl
135360
      */
135360
     void renderDocument(GdkRectangle* pPartial);
135360
     /// Returns the GdkRectangle of a x,y,width,height string.
135360
-    static GdkRectangle payloadToRectangle(const char* pPayload);
135360
+    GdkRectangle payloadToRectangle(const char* pPayload);
135360
     /// Returns the GdkRectangles of a x1,y1,w1,h1;x2,y2,w2,h2;... string.
135360
-    static std::vector<GdkRectangle> payloadToRectangles(const char* pPayload);
135360
+    std::vector<GdkRectangle> payloadToRectangles(const char* pPayload);
135360
     /// Returns the string representation of a LibreOfficeKitCallbackType enumeration element.
135360
     static const char* callbackTypeToString(int nType);
135360
     /// Invoked on the main thread if callbackWorker() requests so.
135360
@@ -853,18 +853,26 @@ GdkRectangle LOKDocView_Impl::payloadToRectangle(const char* pPayload)
135360
     if (!*ppCoordinate)
135360
         return aRet;
135360
     aRet.x = atoi(*ppCoordinate);
135360
+    if (aRet.x < 0)
135360
+        aRet.x = 0;
135360
     ++ppCoordinate;
135360
     if (!*ppCoordinate)
135360
         return aRet;
135360
     aRet.y = atoi(*ppCoordinate);
135360
+    if (aRet.y < 0)
135360
+        aRet.y = 0;
135360
     ++ppCoordinate;
135360
     if (!*ppCoordinate)
135360
         return aRet;
135360
     aRet.width = atoi(*ppCoordinate);
135360
+    if (aRet.x + aRet.width > m_nDocumentWidthTwips)
135360
+        aRet.width = m_nDocumentWidthTwips - aRet.x;
135360
     ++ppCoordinate;
135360
     if (!*ppCoordinate)
135360
         return aRet;
135360
     aRet.height = atoi(*ppCoordinate);
135360
+    if (aRet.y + aRet.height > m_nDocumentHeightTwips)
135360
+        aRet.height = m_nDocumentHeightTwips - aRet.y;
135360
     g_strfreev(ppCoordinates);
135360
     return aRet;
135360
 }
135360
-- 
135360
2.12.0
135360